Ported InvalidUserDataException.
This commit is contained in:
parent
b4bdda26e3
commit
c151acd30b
|
@ -1,25 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace src\PointToolsBundle\Exception\Factory;
|
|
||||||
|
|
||||||
use src\PointToolsBundle\DTO\Api\User as UserDTO;
|
|
||||||
|
|
||||||
class InvalidUserDataException extends \Exception
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var UserDTO
|
|
||||||
*/
|
|
||||||
private $user;
|
|
||||||
|
|
||||||
public function __construct($message = "", UserDTO $user, $code = 0, \Exception $previous = null)
|
|
||||||
{
|
|
||||||
$this->user = $user;
|
|
||||||
|
|
||||||
parent::__construct($message, $code, $previous);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getUser(): UserDTO
|
|
||||||
{
|
|
||||||
return $this->user;
|
|
||||||
}
|
|
||||||
}
|
|
17
src/Exception/Factory/InvalidUserDataException.php
Normal file
17
src/Exception/Factory/InvalidUserDataException.php
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Exception\Factory;
|
||||||
|
|
||||||
|
use App\DTO\Api\User as UserDTO;
|
||||||
|
|
||||||
|
class InvalidUserDataException extends \Exception
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
public readonly UserDTO $user,
|
||||||
|
$code = 0,
|
||||||
|
\Exception $previous = null
|
||||||
|
) {
|
||||||
|
parent::__construct('Invalid user data', $code, $previous);
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,7 +25,7 @@ class UserFactory extends AbstractFactory
|
||||||
// @todo LOG
|
// @todo LOG
|
||||||
|
|
||||||
if (!$userData->isValid()) {
|
if (!$userData->isValid()) {
|
||||||
throw new InvalidUserDataException('Invalid user data', $userData);
|
throw new InvalidUserDataException($userData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
|
|
Loading…
Reference in a new issue