InfiniteEndState   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 69
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A formatEndDate() 0 3 1
A getStartDate() 0 3 1
A setStartDate() 0 3 1
A hasEndDate() 0 3 1
A hasStartDate() 0 3 1
A __construct() 0 3 1
A setEndDate() 0 3 1
A getEndDate() 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 end.
10
 */
11
final class InfiniteEndState extends RangeState
12
{
13
    /**
14
     * @var DateTimeInterface
15
     */
16
    private $startDate;
17
18
    /**
19
     * @param DateTimeInterface $startDate
20
     */
21 13
    public function __construct(DateTimeInterface $startDate)
22
    {
23 13
        $this->startDate = $startDate;
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29 1
    public function hasStartDate(): bool
30
    {
31 1
        return true;
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 1
    public function hasEndDate(): bool
38
    {
39 1
        return false;
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45 3
    public function getStartDate(): DateTimeInterface
46
    {
47 3
        return $this->startDate;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53 2
    public function getEndDate(): DateTimeInterface
54
    {
55 2
        throw new DateRangeException('Range end is undefined');
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61 1
    public function setStartDate(DateTimeInterface $start): RangeState
62
    {
63 1
        return new InfiniteEndState($start);
64
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69 10
    public function setEndDate(DateTimeInterface $end): RangeState
70
    {
71 10
        return new FiniteState($this->startDate, $end);
72
    }
73
74
    /**
75
     * {@inheritdoc}
76
     */
77 3
    public function formatEndDate(string $format = 'c'): ?string
78
    {
79 3
        return null;
80
    }
81
}
82