Test Failed
Branch develop (09cda0)
by Samson
03:06
created

DateTime::toGregorian()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Andegna;
4
5
use DateTime as BaseDateTime;
6
7
/**
8
 * Ethiopian DateTime class.
9
 */
10
class DateTime
11
{
12
    use Operations\Initiator,
13
        Operations\Processor,
14
        Operations\Formatter;
15
16
    /**
17
     * The Gregorian Date
18
     *
19
     * @var BaseDateTime
20
     */
21
    protected $dateTime;
22
23
24
    /** @var int */
25
    protected $year;
26
27
    /** @var int */
28
    protected $month;
29
30
    /** @var int */
31
    protected $day;
32
33
    /** @var int */
34
    protected $leapYear;
35
36
    /** @var int */
37
    protected $dayOfYear;
38
39
    /** @var int */
40
    protected $daysInMonth;
41
42
    /**
43
     * @return BaseDateTime
44
     */
45
    public function getDateTime()
46
    {
47
        return $this->dateTime;
48
    }
49
50
    /**
51
     * @return int
52
     */
53
    public function getYear()
54
    {
55
        return $this->year;
56
    }
57
58
    /**
59
     * @return int
60
     */
61
    public function getMonth()
62
    {
63
        return $this->month;
64
    }
65
66
    /**
67
     * @return int
68
     */
69
    public function getDay()
70
    {
71
        return $this->day;
72
    }
73
74
    /**
75
     * @return int
76
     */
77
    public function getLeapYear()
78
    {
79
        return $this->leapYear;
80
    }
81
82
    /**
83
     * @return int
84
     */
85
    public function getDayOfYear()
86
    {
87
        return $this->dayOfYear;
88
    }
89
90
    /**
91
     * @return int
92
     */
93
    public function getDaysInMonth()
94
    {
95
        return $this->daysInMonth;
96
    }
97
98
    public function getHour()
99
    {
100
        return intval($this->dateTime->format('G'));
101
    }
102
103
    public function getMinute()
104
    {
105
        return intval($this->dateTime->format('i'));
106
    }
107
108
    public function getSecond()
109
    {
110
        return intval($this->dateTime->format('s'));
111
    }
112
113
    public function getMicro()
114
    {
115
        return intval($this->dateTime->format('u'));
116
    }
117
118
119
    public function getDayOfWeek()
120
    {
121
        return intval($this->dateTime->format('N'));
122
    }
123
124
    public function getTimestamp()
125
    {
126
        return intval($this->dateTime->format('U'));
127
    }
128
129
    /**
130
     * DateTime constructor.
131
     *
132
     * @param BaseDateTime|null $dateTime
133
     */
134
    public function __construct(BaseDateTime $dateTime = null)
135
    {
136
        if (null === $dateTime) {
137
            $this->dateTime = new BaseDateTime('now');
138
        } else {
139
            $this->dateTime = $dateTime;
140
        }
141
142
        $this->updateComputedFields();
143
    }
144
145
    /**
146
     * Return the <b>clone</b> of the base gregorian date time.
147
     *
148
     * @return BaseDateTime
149
     */
150
    public function toGregorian()
151
    {
152
        return clone $this->dateTime;
153
    }
154
155
}
156