trafficmonitor/app/DTOs/CertificationDTO.php
2025-11-06 16:51:52 +09:00

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(),
]
);
}
}