Lines
100.00%
4 / 4
Methods
100.00%
4 / 4
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| forDate | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| withEventTime | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| findEventTime | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| 10 | final readonly class SunDay | |
| 11 | { | |
| 12 | /** @param array<string, Instant> $eventTimes */ | |
| 13 | private function __construct( | |
| 14 | public DateTimeImmutable $date, | |
| 15 | private array $eventTimes, | |
| 16 | ) {} | |
| 17 | ||
| 18 | public static function forDate(DateTimeImmutable $date): self | |
| 19 | { | |
| 20 | return new self($date->setTime(0, 0), []); | |
| 21 | } | |
| 22 | ||
| 23 | public function withEventTime(SunEvent $event, Instant $time): self | |
| 24 | { | |
| 25 | return new self($this->date, [...$this->eventTimes, $event->value => $time]); | |
| 26 | } | |
| 27 | ||
| 28 | public function findEventTime(SunEvent $event): ?Instant | |
| 29 | { | |
| 30 | return $this->eventTimes[$event->value] ?? null; | |
| 31 | } | |
| 32 | } |