Refactor exception handling in ClientNameAlreadyExistsException and ClientNotFoundException to utilize value objects directly, improving type safety and clarity.
15 lines
377 B
PHP
15 lines
377 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Application\Security\Exceptions;
|
|
|
|
use Application\Security\Models\ValueObjects\ClientName;
|
|
|
|
final class ClientNameAlreadyExistsException extends \DomainException
|
|
{
|
|
public static function forName(ClientName $name): self
|
|
{
|
|
return new self("A client with the name '{$name->value}' (or similar) already exists.");
|
|
}
|
|
}
|