InfiniteStartState   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 61
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A hasEndDate() 0 3 1
A formatStartDate() 0 3 1
A setEndDate() 0 3 1
A getEndDate() 0 3 1
A __construct() 0 3 1
A setStartDate() 0 3 1
A getStartDate() 0 3 1
1
<?php
2
3
namespace Zee\DateRange\States;
4
5
use DateTimeInterface;
6
use Zee\DateRange\DateRangeException;
7
8
/**
9
 * State of the range with infinite start.
10
 */
11
final class InfiniteStartState extends RangeState
12
{
13
    /**
14
     * @var DateTimeInterface
15
     */
16
    private $endDate;
17
18
    /**
19
     * @param DateTimeInterface $endDate
20
     */
21 7
    public function __construct(DateTimeInterface $endDate)
22
    {
23 7
        $this->endDate = $endDate;
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29 2
    public function hasEndDate(): bool
30
    {
31 2
        return true;
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 2
    public function getStartDate(): DateTimeInterface
38
    {
39 2
        throw new DateRangeException('Range start is undefined');
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45 4
    public function getEndDate(): DateTimeInterface
46
    {
47 4
        return $this->endDate;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53 1
    public function setStartDate(DateTimeInterface $start): RangeState
54
    {
55 1
        return new FiniteState($start, $this->endDate);
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61 1
    public function setEndDate(DateTimeInterface $end): RangeState
62
    {
63 1
        return new InfiniteStartState($end);
64
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69 3
    public function formatStartDate(string $format = 'c'): ?string
70
    {
71 3
        return null;
72
    }
73
}
74