Code Duplication    Length = 32-32 lines in 2 locations

src/Month/MonthIntervalPoint.php 1 location

@@ 15-46 (lines=32) @@
12
13
use GpsLab\Component\Interval\BaseIntervalPoint;
14
15
class MonthIntervalPoint extends BaseIntervalPoint
16
{
17
    /**
18
     * @var \DateTime
19
     */
20
    private $month;
21
22
    /**
23
     * @param \DateTime $date
24
     */
25
    public function __construct(\DateTime $date)
26
    {
27
        $this->month = clone $date;
28
        $this->month->setDate($date->format('Y'), $date->format('m'), 1)->setTime(0, 0, 0);
29
    }
30
31
    /**
32
     * @return \DateTime
33
     */
34
    public function value()
35
    {
36
        return clone $this->month;
37
    }
38
39
    /**
40
     * @return string
41
     */
42
    public function __toString()
43
    {
44
        return $this->value()->format('Y/m');
45
    }
46
}
47

src/Year/YearIntervalPoint.php 1 location

@@ 15-46 (lines=32) @@
12
13
use GpsLab\Component\Interval\BaseIntervalPoint;
14
15
class YearIntervalPoint extends BaseIntervalPoint
16
{
17
    /**
18
     * @var \DateTime
19
     */
20
    private $year;
21
22
    /**
23
     * @param \DateTime $date
24
     */
25
    public function __construct(\DateTime $date)
26
    {
27
        $this->year = clone $date;
28
        $this->year->setDate($date->format('Y'), 1, 1)->setTime(0, 0, 0);
29
    }
30
31
    /**
32
     * @return \DateTime
33
     */
34
    public function value()
35
    {
36
        return clone $this->year;
37
    }
38
39
    /**
40
     * @return string
41
     */
42
    public function __toString()
43
    {
44
        return $this->value()->format('Y');
45
    }
46
}
47