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

UndefinedRange   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 80
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0
wmc 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A hasStartTime() 0 3 1
A getEndTime() 0 3 1
A getStartTime() 0 3 1
A jsonSerialize() 0 3 1
A setEndTime() 0 3 1
A setStartTime() 0 3 1
A hasEndTime() 0 3 1
A __toString() 0 3 1
A compareEndTime() 0 3 1
A compareStartTime() 0 3 1
1
<?php
2
3
namespace Zee\DateRange\States;
4
5
use DateTimeInterface;
6
use Zee\DateRange\DateRangeException;
7
8
/**
9
 * Class UndefinedRange.
10
 */
11
class UndefinedRange implements RangeState
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16 1
    public function __toString(): string
17
    {
18 1
        return '-/-';
19
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24 1
    public function jsonSerialize(): array
25
    {
26 1
        return ['startTime' => null, 'endTime' => null];
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32 2
    public function hasStartTime(): bool
33
    {
34 2
        return false;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 2
    public function hasEndTime(): bool
41
    {
42 2
        return false;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48 2
    public function getStartTime(): DateTimeInterface
49
    {
50 2
        throw new DateRangeException('Range start is undefined');
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56 2
    public function getEndTime(): DateTimeInterface
57
    {
58 2
        throw new DateRangeException('Range end is undefined');
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64 7
    public function setStartTime(DateTimeInterface $time): RangeState
65
    {
66 7
        return new InfiniteEndRange($time);
67
    }
68
69
    /**
70
     * {@inheritdoc}
71
     */
72 3
    public function setEndTime(DateTimeInterface $time): RangeState
73
    {
74 3
        return new InfiniteStartRange($time);
75
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80 1
    public function compareStartTime(DateTimeInterface $time): int
81
    {
82 1
        throw new DateRangeException('Range start is undefined');
83
    }
84
85
    /**
86
     * {@inheritdoc}
87
     */
88 1
    public function compareEndTime(DateTimeInterface $time): int
89
    {
90 1
        throw new DateRangeException('Range end is undefined');
91
    }
92
}
93