| Total Complexity | 10 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 20 | class Identity |
||
| 21 | { |
||
| 22 | private string $name, $email; |
||
| 23 | private ?\DateTimeInterface $date = null; |
||
| 24 | |||
| 25 | public function __construct(string $name, string $email, \DateTimeInterface|string $date = null) |
||
| 26 | { |
||
| 27 | $this->name = $name; |
||
| 28 | $this->email = $email; |
||
| 29 | |||
| 30 | if (null !== $date) { |
||
| 31 | $this->setDate($date); |
||
| 32 | } |
||
| 33 | } |
||
| 34 | |||
| 35 | public function setName(string $name): self |
||
| 36 | { |
||
| 37 | $this->name = $name; |
||
| 38 | |||
| 39 | return $this; |
||
| 40 | } |
||
| 41 | |||
| 42 | public function getName(): string |
||
| 43 | { |
||
| 44 | return $this->name; |
||
| 45 | } |
||
| 46 | |||
| 47 | public function setEmail(string $email): self |
||
| 48 | { |
||
| 49 | $this->email = $email; |
||
| 50 | |||
| 51 | return $this; |
||
| 52 | } |
||
| 53 | |||
| 54 | public function getEmail(): string |
||
| 55 | { |
||
| 56 | return $this->email; |
||
| 57 | } |
||
| 58 | |||
| 59 | public function setDate(\DateTimeInterface|string $date): self |
||
| 60 | { |
||
| 61 | if (\is_string($date)) { |
||
| 62 | $date = new \DateTimeImmutable(\is_numeric($date) ? '@'.$date : $date); |
||
| 63 | } |
||
| 64 | $this->date = $date; |
||
| 65 | |||
| 66 | return $this; |
||
| 67 | } |
||
| 68 | |||
| 69 | public function getDate(): ?\DateTimeInterface |
||
| 72 | } |
||
| 73 | } |
||
| 74 |