Total Complexity | 9 |
Total Lines | 82 |
Duplicated Lines | 0 % |
Coverage | 50% |
Changes | 0 |
1 | <?php |
||
13 | final class Trimester |
||
14 | { |
||
15 | /** |
||
16 | * @var int |
||
17 | */ |
||
18 | private $value; |
||
19 | |||
20 | /** |
||
21 | * @param int $value |
||
22 | */ |
||
23 | 16 | private function __construct(int $value) |
|
24 | { |
||
25 | 16 | Assert::range($value, 1, 4); |
|
26 | 16 | $this->value = $value; |
|
27 | 16 | } |
|
28 | |||
29 | /** |
||
30 | * @return int |
||
31 | */ |
||
32 | 16 | public function value(): int |
|
33 | { |
||
34 | 16 | return $this->value; |
|
35 | } |
||
36 | |||
37 | /** |
||
38 | * @param Trimester $trimester |
||
39 | * @return bool |
||
40 | */ |
||
41 | 16 | public function equals(Trimester $trimester): bool |
|
42 | { |
||
43 | 16 | return $this->value === $trimester->value(); |
|
44 | } |
||
45 | |||
46 | /** |
||
47 | * @return Trimester |
||
48 | */ |
||
49 | public static function first(): self |
||
50 | { |
||
51 | return new self(1); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @return Trimester |
||
56 | */ |
||
57 | public static function second(): self |
||
58 | { |
||
59 | return new self(2); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * @return Trimester |
||
64 | */ |
||
65 | public static function third(): self |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * @return Trimester |
||
72 | */ |
||
73 | public static function fourth(): self |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * @return Trimester |
||
80 | */ |
||
81 | public static function now(): self |
||
85 | } |
||
86 | |||
87 | /** |
||
88 | * @param \DateTimeInterface $date |
||
89 | * @return Trimester |
||
90 | */ |
||
91 | 16 | public static function fromNDateTime(\DateTimeInterface $date): self |
|
97 |