DateTimeIntervalPoint::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
/**
4
 * GpsLab component.
5
 *
6
 * @author    Peter Gribanov <[email protected]>
7
 * @copyright Copyright (c) 2016, Peter Gribanov
8
 * @license   http://opensource.org/licenses/MIT
9
 */
10
11
namespace GpsLab\Component\Interval\DateTime;
12
13
use GpsLab\Component\Interval\BaseIntervalPoint;
14
15
class DateTimeIntervalPoint extends BaseIntervalPoint
16
{
17
    /**
18
     * @var \DateTime
19
     */
20
    private $date;
21
22
    /**
23
     * @param \DateTime $date
24
     */
25 4
    public function __construct(\DateTime $date)
26
    {
27 4
        $this->date = clone $date;
28 4
    }
29
30
    /**
31
     * @return \DateTime
32
     */
33 4
    public function value()
34
    {
35 4
        return clone $this->date;
36
    }
37
38
    /**
39
     * @return string
40
     */
41 1
    public function __toString()
42
    {
43 1
        return $this->value()->format('Y-m-d H:i:s');
44
    }
45
}
46