TimeIntervalPoint::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 5
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 5
loc 5
ccs 4
cts 4
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\Time;
12
13
use GpsLab\Component\Interval\BaseIntervalPoint;
14
15 View Code Duplication
class TimeIntervalPoint extends BaseIntervalPoint
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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
        $this->date->setDate(1, 1, 1);
29 4
    }
30
31
    /**
32
     * @return \DateTime
33
     */
34 4
    public function value()
35
    {
36 4
        return clone $this->date;
37
    }
38
39
    /**
40
     * @return string
41
     */
42 1
    public function __toString()
43
    {
44 1
        return $this->value()->format('H:i:s');
45
    }
46
}
47