34 lines
726 B
PHP
34 lines
726 B
PHP
<?php
|
|
|
|
namespace App\DTOs;
|
|
|
|
use App\Services\Auth\AuthService;
|
|
|
|
class CertificationDTO extends CommonDTO
|
|
{
|
|
public bool $isLogin = false;
|
|
public ?int $uid = null;
|
|
public ?string $name = null;
|
|
public ?string $role = null;
|
|
public function __construct(array $datas = [])
|
|
{
|
|
parent::__construct();
|
|
foreach ($datas as $key => $value) {
|
|
if (property_exists($this, $key)) {
|
|
$this->{$key} = $value;
|
|
}
|
|
}
|
|
}
|
|
public static function fromByAuthService(AuthService $service): self
|
|
{
|
|
return new self(
|
|
[
|
|
'isLogin' => $service->isLoggedIn(),
|
|
'uid' => $service->getUID(),
|
|
'name' => $service->getName(),
|
|
'role' => $service->getRole(),
|
|
]
|
|
);
|
|
}
|
|
}
|