Total Complexity | 6 |
Total Lines | 64 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
14 | class Date extends TdObject |
||
15 | { |
||
16 | public const TYPE_NAME = 'date'; |
||
17 | |||
18 | /** |
||
19 | * Day of the month, 1-31. |
||
20 | * |
||
21 | * @var int |
||
22 | */ |
||
23 | protected int $day; |
||
24 | |||
25 | /** |
||
26 | * Month, 1-12. |
||
27 | * |
||
28 | * @var int |
||
29 | */ |
||
30 | protected int $month; |
||
31 | |||
32 | /** |
||
33 | * Year, 1-9999. |
||
34 | * |
||
35 | * @var int |
||
36 | */ |
||
37 | protected int $year; |
||
38 | |||
39 | public function __construct(int $day, int $month, int $year) |
||
40 | { |
||
41 | $this->day = $day; |
||
42 | $this->month = $month; |
||
43 | $this->year = $year; |
||
44 | } |
||
45 | |||
46 | public static function fromArray(array $array): Date |
||
47 | { |
||
48 | return new static( |
||
49 | $array['day'], |
||
50 | $array['month'], |
||
51 | $array['year'], |
||
52 | ); |
||
53 | } |
||
54 | |||
55 | public function typeSerialize(): array |
||
56 | { |
||
57 | return [ |
||
58 | '@type' => static::TYPE_NAME, |
||
59 | 'day' => $this->day, |
||
60 | 'month' => $this->month, |
||
61 | 'year' => $this->year, |
||
62 | ]; |
||
63 | } |
||
64 | |||
65 | public function getDay(): int |
||
66 | { |
||
67 | return $this->day; |
||
68 | } |
||
69 | |||
70 | public function getMonth(): int |
||
73 | } |
||
74 | |||
75 | public function getYear(): int |
||
78 | } |
||
79 | } |
||
80 |