mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-09-30 00:09:13 +02:00
PHP8
This commit is contained in:
@@ -4,9 +4,6 @@ namespace DesignPatterns\Structural\DataMapper;
|
||||
|
||||
class User
|
||||
{
|
||||
private string $username;
|
||||
private string $email;
|
||||
|
||||
public static function fromState(array $state): User
|
||||
{
|
||||
// validate state before accessing keys!
|
||||
@@ -17,12 +14,8 @@ class User
|
||||
);
|
||||
}
|
||||
|
||||
public function __construct(string $username, string $email)
|
||||
public function __construct(private string $username, private string $email)
|
||||
{
|
||||
// validate parameters before setting them!
|
||||
|
||||
$this->username = $username;
|
||||
$this->email = $email;
|
||||
}
|
||||
|
||||
public function getUsername(): string
|
||||
|
Reference in New Issue
Block a user