Second::isValid()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace CalendR\Period;
4
5
/**
6
 * Represents a second.
7
 *
8
 * @author Zander Baldwin <[email protected]>
9
 */
10
class Second extends PeriodAbstract
11
{
12
    /**
13
     * Returns the period as a DatePeriod.
14
     *
15
     * @return \DatePeriod
16
     */
17
    public function getDatePeriod()
18
    {
19
        return new \DatePeriod($this->begin, new \DateInterval('PT1S'), $this->end);
20
    }
21
22
    /**
23
     * @param \DateTime $start
24
     *
25
     * @return bool
26
     */
27
    public static function isValid(\DateTime $start)
28
    {
29
        return $start->format('u') === '000000';
30
    }
31
32
    /**
33
     * Returns the second.
34
     *
35
     * @return string
36
     */
37
    public function __toString()
38
    {
39
        return $this->format('s');
40
    }
41
42
    /**
43
     * Returns a \DateInterval equivalent to the period.
44
     *
45
     * @return \DateInterval
46
     */
47
    public static function getDateInterval()
48
    {
49
        return new \DateInterval('PT1S');
50
    }
51
}
52