Completed
Push — master ( af3bdc...8a0335 )
by Veaceslav
01:57
created

InfiniteEndRange::getStartTime()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 3
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 3
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Zee\DateRange\States;
4
5
use DateTimeInterface;
6
7
/**
8
 * Class InfiniteEndRange.
9
 */
10 View Code Duplication
final class InfiniteEndRange extends UndefinedRange
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...
11
{
12
    /**
13
     * @var DateTimeInterface
14
     */
15
    private $startTime;
16
17
    /**
18
     * @param DateTimeInterface $startTime
19
     */
20 7
    public function __construct(DateTimeInterface $startTime)
21
    {
22 7
        $this->startTime = $startTime;
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28 1
    public function __toString(): string
29
    {
30 1
        return sprintf('%s/-', $this->startTime->format('c'));
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36 1
    public function jsonSerialize(): array
37
    {
38 1
        return ['startTime' => $this->startTime->format('c'), 'endTime' => null];
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44 1
    public function hasStartTime(): bool
45
    {
46 1
        return true;
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52 2
    public function getStartTime(): DateTimeInterface
53
    {
54 2
        return $this->startTime;
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60 1
    public function setStartTime(DateTimeInterface $time): RangeState
61
    {
62 1
        return new InfiniteEndRange($time);
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68 5
    public function setEndTime(DateTimeInterface $time): RangeState
69
    {
70 5
        return new FiniteRange($this->startTime, $time);
71
    }
72
73
    /**
74
     * {@inheritdoc}
75
     */
76 1
    public function compareStartTime(DateTimeInterface $time): int
77
    {
78 1
        return $this->startTime->getTimestamp() <=> $time->getTimestamp();
79
    }
80
}
81