Date::fromArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This phpFile is auto-generated.
5
 */
6
7
declare(strict_types=1);
8
9
namespace PHPTdGram\Schema;
10
11
/**
12
 * Represents a date according to the Gregorian calendar.
13
 */
14
class Date extends TdObject
15
{
16
    public const TYPE_NAME = 'date';
17
18
    /**
19
     * Day of the month, 1-31.
20
     */
21
    protected int $day;
22
23
    /**
24
     * Month, 1-12.
25
     */
26
    protected int $month;
27
28
    /**
29
     * Year, 1-9999.
30
     */
31
    protected int $year;
32
33
    public function __construct(int $day, int $month, int $year)
34
    {
35
        $this->day   = $day;
36
        $this->month = $month;
37
        $this->year  = $year;
38
    }
39
40
    public static function fromArray(array $array): Date
41
    {
42
        return new static(
43
            $array['day'],
44
            $array['month'],
45
            $array['year'],
46
        );
47
    }
48
49
    public function typeSerialize(): array
50
    {
51
        return [
52
            '@type' => static::TYPE_NAME,
53
            'day'   => $this->day,
54
            'month' => $this->month,
55
            'year'  => $this->year,
56
        ];
57
    }
58
59
    public function getDay(): int
60
    {
61
        return $this->day;
62
    }
63
64
    public function getMonth(): int
65
    {
66
        return $this->month;
67
    }
68
69
    public function getYear(): int
70
    {
71
        return $this->year;
72
    }
73
}
74