Conditions | 12 |
Paths | 6 |
Total Lines | 56 |
Code Lines | 33 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
141 | public function list() |
||
142 | { |
||
143 | if (!$this->api_key) { |
||
144 | throw new \Exception('Providing an API key might be a better start. RTFM.'); |
||
145 | } |
||
146 | |||
147 | if (!$this->country_code) { |
||
148 | throw new \Exception('Providing a Country Code is a good idea. RTFM.'); |
||
149 | } |
||
150 | |||
151 | $result = []; |
||
152 | |||
153 | $api_url = "https://content.googleapis.com/calendar/v3/calendars/en.{$this->country_code}%23holiday%40group.v.calendar.google.com/events". |
||
154 | '?singleEvents=false'. |
||
155 | "&timeMax={$this->end_date}". |
||
156 | "&timeMin={$this->start_date}". |
||
157 | "&key={$this->api_key}"; |
||
158 | |||
159 | $response = json_decode(file_get_contents($api_url), true); |
||
160 | |||
161 | if (isset($response['items'])) { |
||
162 | if ($this->dates_only === true) { |
||
163 | foreach ($response['items'] as $holiday) { |
||
164 | $result[] = $holiday['start']['date']; |
||
165 | } |
||
166 | |||
167 | sort($result); |
||
168 | } elseif ($this->minimal === true) { |
||
169 | foreach ($response['items'] as $holiday) { |
||
170 | $result[] = [ |
||
171 | 'name' => $holiday['summary'], |
||
172 | 'date' => $holiday['start']['date'], |
||
173 | ]; |
||
174 | } |
||
175 | |||
176 | usort($result, function ($a, $b) { |
||
177 | if ($a['date'] == $b['date']) { |
||
178 | return 0; |
||
179 | } |
||
180 | |||
181 | return ($a['date'] < $b['date']) ? -1 : 1; |
||
182 | }); |
||
183 | } else { |
||
184 | $result = $response['items']; |
||
185 | |||
186 | usort($result, function ($a, $b) { |
||
187 | if ($a['start']['date'] == $b['start']['date']) { |
||
188 | return 0; |
||
189 | } |
||
190 | |||
191 | return ($a['start']['date'] < $b['start']['date']) ? -1 : 1; |
||
192 | }); |
||
193 | } |
||
194 | } |
||
195 | |||
196 | return $result; |
||
197 | } |
||
199 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths