| Total Complexity | 9 |
| Total Lines | 44 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | final class ObservanceDecorator implements HolidayIteratorItemInterface |
||
| 16 | { |
||
| 17 | /** @var int|null */ |
||
| 18 | private $firstObservance; |
||
| 19 | |||
| 20 | /** @var int|null */ |
||
| 21 | private $lastObservance; |
||
| 22 | |||
| 23 | /** @var HolidayIteratorItemInterface */ |
||
| 24 | private $wrapped; |
||
| 25 | |||
| 26 | public function __construct(HolidayIteratorItemInterface $wrapped, ?int $firstObservance, ?int $lastObservance) |
||
| 31 | } |
||
| 32 | |||
| 33 | public function dateMatches(DateTimeInterface $date): bool |
||
| 34 | { |
||
| 35 | if (!$this->isWithinObservance((int) $date->format('Y'))) { |
||
| 36 | return false; |
||
| 37 | } |
||
| 38 | |||
| 39 | return $this->wrapped->dateMatches($date); |
||
| 40 | } |
||
| 41 | |||
| 42 | private function isWithinObservance(int $gregorianYear): bool |
||
| 43 | { |
||
| 44 | if (null !== $this->firstObservance && $this->firstObservance > $gregorianYear) { |
||
| 45 | return false; |
||
| 46 | } |
||
| 47 | |||
| 48 | return null === $this->lastObservance || $this->lastObservance >= $gregorianYear; |
||
| 49 | } |
||
| 50 | |||
| 51 | public function getName(): string |
||
| 54 | } |
||
| 55 | |||
| 56 | public function isHoliday(): bool |
||
| 59 | } |
||
| 60 | } |
||
| 61 |