37 lines
861 B
PHP
37 lines
861 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Application\DTO;
|
|
|
|
use App\Domain\Model\Persisted\PersistedUser;
|
|
use OpenApi\Attributes as OA;
|
|
|
|
#[OA\Schema]
|
|
final readonly class UserDTO
|
|
{
|
|
public function __construct(
|
|
#[OA\Property(type: 'string')]
|
|
public string $id,
|
|
#[OA\Property(type: 'string')]
|
|
public string $email,
|
|
#[OA\Property(type: 'string')]
|
|
public string $firstName,
|
|
#[OA\Property(type: 'string')]
|
|
public string $lastName,
|
|
#[OA\Property(type: 'string')]
|
|
public string $fullName
|
|
) {
|
|
}
|
|
|
|
public static function fromEntity(PersistedUser $user): self
|
|
{
|
|
return new self(
|
|
$user->getId(),
|
|
$user->getEmail(),
|
|
$user->getFirstName(),
|
|
$user->getLastName(),
|
|
$user->getFullName()
|
|
);
|
|
}
|
|
}
|