Completed
Push — master ( caad92...bf4c7a )
by Peter
05:39
created

TimeIntervalPoint   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 0
dl 0
loc 92
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A value() 0 4 1
A eq() 0 4 1
A neq() 0 4 1
A lt() 0 4 1
A lte() 0 4 1
A gt() 0 4 1
A gte() 0 4 1
A __toString() 0 4 1
1
<?php 
2
/**
3
 * GpsLab component.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2016, Peter Gribanov
7
 * @license   http://opensource.org/licenses/MIT
8
 */
9
10
namespace GpsLab\Component\Interval\Time;
11
12
use GpsLab\Component\Interval\PointInterface;
13
14
class TimeIntervalPoint implements PointInterface
15
{
16
    /**
17
     * @var \DateTime
18
     */
19
    private $date;
20
21
    /**
22
     * @param \DateTime $date
23
     */
24
    public function __construct(\DateTime $date)
25
    {
26
        $this->date = clone $date;
27
        $this->date->setDate(1, 1, 1);
28
    }
29
30
    /**
31
     * @return \DateTime
32
     */
33
    public function value()
34
    {
35
        return clone $this->date;
36
    }
37
38
    /**
39
     * @param TimeIntervalPoint $point
40
     *
41
     * @return bool
42
     */
43
    public function eq(TimeIntervalPoint $point)
44
    {
45
        return $this->value() == $point->value();
46
    }
47
48
    /**
49
     * @param TimeIntervalPoint $point
50
     *
51
     * @return bool
52
     */
53
    public function neq(TimeIntervalPoint $point)
54
    {
55
        return $this->value() != $point->value();
56
    }
57
58
    /**
59
     * @param TimeIntervalPoint $point
60
     *
61
     * @return bool
62
     */
63
    public function lt(TimeIntervalPoint $point)
64
    {
65
        return $this->value() < $point->value();
66
    }
67
68
    /**
69
     * @param TimeIntervalPoint $point
70
     *
71
     * @return bool
72
     */
73
    public function lte(TimeIntervalPoint $point)
74
    {
75
        return $this->value() <= $point->value();
76
    }
77
78
    /**
79
     * @param TimeIntervalPoint $point
80
     *
81
     * @return bool
82
     */
83
    public function gt(TimeIntervalPoint $point)
84
    {
85
        return $this->value() > $point->value();
86
    }
87
88
    /**
89
     * @param TimeIntervalPoint $point
90
     *
91
     * @return bool
92
     */
93
    public function gte(TimeIntervalPoint $point)
94
    {
95
        return $this->value() >= $point->value();
96
    }
97
98
    /**
99
     * @return string
100
     */
101
    public function __toString()
102
    {
103
        return $this->value()->format('H:i:s');
104
    }
105
}
106