| Total Complexity | 9 |
| Total Lines | 77 |
| Duplicated Lines | 0 % |
| Coverage | 47.37% |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | final class DayInWeek implements TemporalExpressionInterface |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @var WeekDay |
||
| 17 | */ |
||
| 18 | protected $day; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @param WeekDay $day |
||
| 22 | */ |
||
| 23 | 2 | private function __construct(WeekDay $day) |
|
| 24 | { |
||
| 25 | 2 | $this->day = $day; |
|
| 26 | 2 | } |
|
| 27 | |||
| 28 | /** |
||
| 29 | * {@inheritdoc} |
||
| 30 | */ |
||
| 31 | 2 | public function includes(DateTimeInterface $date): bool |
|
| 32 | { |
||
| 33 | 2 | return $this->day->equals(WeekDay::fromDateTime($date)); |
|
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @return DayInWeek |
||
| 38 | */ |
||
| 39 | public static function monday(): self |
||
| 40 | { |
||
| 41 | return new self(WeekDay::monday()); |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @return DayInWeek |
||
| 46 | */ |
||
| 47 | public static function tuesday(): self |
||
| 48 | { |
||
| 49 | return new self(WeekDay::tuesday()); |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @return DayInWeek |
||
| 54 | */ |
||
| 55 | public static function wednesday(): self |
||
| 56 | { |
||
| 57 | return new self(WeekDay::wednesday()); |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @return DayInWeek |
||
| 62 | */ |
||
| 63 | public static function thursday(): self |
||
| 64 | { |
||
| 65 | return new self(WeekDay::thursday()); |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @return DayInWeek |
||
| 70 | */ |
||
| 71 | 1 | public static function friday(): self |
|
| 72 | { |
||
| 73 | 1 | return new self(WeekDay::friday()); |
|
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @return DayInWeek |
||
| 78 | */ |
||
| 79 | public static function saturday(): self |
||
| 80 | { |
||
| 81 | return new self(WeekDay::saturday()); |
||
| 82 | } |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @return DayInWeek |
||
| 86 | */ |
||
| 87 | 1 | public static function sunday(): self |
|
| 90 | } |
||
| 91 | } |
||
| 92 |