GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( a3c5fc...13d483 )
by Dragos
11:38
created

TimeInterval   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 83
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 2
A fromString() 0 4 1
A contains() 0 4 2
A getStart() 0 4 1
A getEnd() 0 4 1
A jsonSerialize() 0 7 1
1
<?php
2
3
namespace Speicher210\BusinessHours\Day\Time;
4
5
/**
6
 * Represents a time interval.
7
 */
8
class TimeInterval implements TimeIntervalInterface
9
{
10
    /**
11
     * The start time.
12
     *
13
     * @var Time
14
     */
15
    protected $start;
16
17
    /**
18
     * The end time.
19
     *
20
     * @var Time
21
     */
22
    protected $end;
23
24
    /**
25
     * Constructor.
26
     *
27
     * @param Time $start The start time.
28
     * @param Time $end The end time.
29
     * @throws \InvalidArgumentException If the opening time is not earlier than closing time.
30
     */
31
    public function __construct(Time $start, Time $end)
32
    {
33
        $this->start = $start;
34
        $this->end = $end;
35
36
        if ($start->isAfterOrEqual($end)) {
37
            throw new \InvalidArgumentException(
38
                sprintf('The opening time "%s" must be before the closing time "%s".', $start, $end)
39
            );
40
        }
41
    }
42
43
    /**
44
     * Create a new interval from time strings.
45
     *
46
     * @param string $startTime The start time
47
     * @param string $endTime The end time
48
     * @return TimeInterval
49
     * @throws \InvalidArgumentException
50
     */
51
    public static function fromString($startTime, $endTime)
52
    {
53
        return new static(TimeBuilder::fromString($startTime), TimeBuilder::fromString($endTime));
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function contains(Time $time)
60
    {
61
        return $this->start->isBeforeOrEqual($time) && $this->end->isAfterOrEqual($time);
62
    }
63
64
    /**
65
     * {@inheritdoc}
66
     */
67
    public function getStart()
68
    {
69
        return $this->start;
70
    }
71
72
    /**
73
     * {@inheritdoc}
74
     */
75
    public function getEnd()
76
    {
77
        return $this->end;
78
    }
79
80
    /**
81
     * {@inheritdoc}
82
     */
83
    public function jsonSerialize()
84
    {
85
        return array(
86
            'start' => $this->start,
87
            'end' => $this->end,
88
        );
89
    }
90
}
91