File size: 848 Bytes
cf14c12 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | <?php
declare(strict_types=1);
namespace Plugin\Domain\ValueObjects;
use JsonSerializable;
class Author implements JsonSerializable
{
public readonly AuthorName $name;
public readonly Email $email;
public readonly Url $homepage;
public readonly Role $role;
public function __construct(
string $name,
?string $email = null,
?string $homepage = null,
?string $role = null
) {
$this->name = new AuthorName($name);
$this->email = new Email($email);
$this->homepage = new Url($homepage);
$this->role = new Role($role);
}
public function jsonSerialize(): mixed
{
return [
'name' => $this->name,
'email' => $this->email,
'homepage' => $this->homepage,
'role' => $this->role
];
}
}
|