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
Pull Request — master (#177)
by Eric
65:22 queued 62:22
created

OpeningHours::hasPeriod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Ivory Google Map package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\GoogleMap\Service\Place\Base;
13
14
/**
15
 * @author GeLo <[email protected]>
16
 */
17
class OpeningHours
18
{
19
    /**
20
     * @var bool|null
21
     */
22
    private $openNow;
23
24
    /**
25
     * @var Period[]
26
     */
27
    private $periods = [];
28
29
    /**
30
     * @var string[]
31
     */
32
    private $weekdayTexts = [];
33
34
    /**
35
     * @return bool
36
     */
37
    public function hasOpenNow()
38
    {
39
        return $this->openNow !== null;
40
    }
41
42
    /**
43
     * @return bool|null
44
     */
45
    public function isOpenNow()
46
    {
47
        return $this->openNow;
48
    }
49
50
    /**
51
     * @param bool|null $openNow
52
     */
53
    public function setOpenNow($openNow)
54
    {
55
        $this->openNow = $openNow;
56
    }
57
58
    /**
59
     * @return bool
60
     */
61
    public function hasPeriods()
62
    {
63
        return !empty($this->periods);
64
    }
65
66
    /**
67
     * @return Period[]
68
     */
69
    public function getPeriods()
70
    {
71
        return $this->periods;
72
    }
73
74
    /**
75
     * @param Period[] $periods
76
     */
77
    public function setPeriods(array $periods)
78
    {
79
        $this->periods = [];
80
        $this->addPeriods($periods);
81
    }
82
83
    /**
84
     * @param Period[] $periods
85
     */
86
    public function addPeriods(array $periods)
87
    {
88
        foreach ($periods as $period) {
89
            $this->addPeriod($period);
90
        }
91
    }
92
93
    /**
94
     * @param Period $period
95
     *
96
     * @return bool
97
     */
98
    public function hasPeriod(Period $period)
99
    {
100
        return in_array($period, $this->periods, true);
101
    }
102
103
    /**
104
     * @param Period $period
105
     */
106
    public function addPeriod(Period $period)
107
    {
108
        if (!$this->hasPeriod($period)) {
109
            $this->periods[] = $period;
110
        }
111
    }
112
113
    /**
114
     * @param Period $period
115
     */
116
    public function removePeriod(Period $period)
117
    {
118
        unset($this->periods[array_search($period, $this->periods, true)]);
119
        $this->periods = array_values($this->periods);
120
    }
121
122
    /**
123
     * @return bool
124
     */
125
    public function hasWeekdayTexts()
126
    {
127
        return !empty($this->weekdayTexts);
128
    }
129
130
    /**
131
     * @return \string[]
132
     */
133
    public function getWeekdayTexts()
134
    {
135
        return $this->weekdayTexts;
136
    }
137
138
    /**
139
     * @param string[] $weekdayTexts
140
     */
141
    public function setWeekdayTexts(array $weekdayTexts)
142
    {
143
        $this->weekdayTexts = [];
144
        $this->addWeekdayTexts($weekdayTexts);
145
    }
146
147
    /**
148
     * @param string[] $weekdayTexts
149
     */
150
    public function addWeekdayTexts(array $weekdayTexts)
151
    {
152
        foreach ($weekdayTexts as $weekdayText) {
153
            $this->addWeekdayText($weekdayText);
154
        }
155
    }
156
157
    /**
158
     * @param string $weekdayText
159
     *
160
     * @return bool
161
     */
162
    public function hasWeekdayText($weekdayText)
163
    {
164
        return in_array($weekdayText, $this->weekdayTexts, true);
165
    }
166
167
    /**
168
     * @param string $weekdayText
169
     */
170
    public function addWeekdayText($weekdayText)
171
    {
172
        if (!$this->hasWeekdayText($weekdayText)) {
173
            $this->weekdayTexts[] = $weekdayText;
174
        }
175
    }
176
177
    /**
178
     * @param string $weekdayText
179
     */
180
    public function removeWeekdayText($weekdayText)
181
    {
182
        unset($this->weekdayTexts[array_search($weekdayText, $this->weekdayTexts, true)]);
183
        $this->weekdayTexts = array_values($this->weekdayTexts);
184
    }
185
}
186