update deploy
This commit is contained in:
43
app/DTOs/UserData.php
Normal file
43
app/DTOs/UserData.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs;
|
||||
|
||||
class UserData
|
||||
{
|
||||
public function __construct(
|
||||
public readonly string $name,
|
||||
public readonly string $email,
|
||||
public readonly ?string $password = null,
|
||||
public readonly ?string $role = null,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
public static function fromArray(array $data): self
|
||||
{
|
||||
return new self(
|
||||
name: $data['name'],
|
||||
email: $data['email'],
|
||||
password: $data['password'] ?? null,
|
||||
role: $data['role'] ?? null,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
$result = [
|
||||
'name' => $this->name,
|
||||
'email' => $this->email,
|
||||
];
|
||||
|
||||
if ($this->password !== null) {
|
||||
$result['password'] = $this->password;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user