| 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 |
||
| 137 | public function list() |
||
| 138 | { |
||
| 139 | if (!$this->api_key) { |
||
| 140 | throw new \Exception('Providing an API key might be a better start. RTFM.'); |
||
| 141 | } |
||
| 142 | |||
| 143 | if (!$this->country_code) { |
||
| 144 | throw new \Exception('Providing a Country Code is a good idea. RTFM.'); |
||
| 145 | } |
||
| 146 | |||
| 147 | $result = []; |
||
| 148 | |||
| 149 | $api_url = "https://content.googleapis.com/calendar/v3/calendars/en.{$this->country_code}%23holiday%40group.v.calendar.google.com/events". |
||
| 150 | '?singleEvents=false'. |
||
| 151 | "&timeMax={$this->end_date}". |
||
| 152 | "&timeMin={$this->start_date}". |
||
| 153 | "&key={$this->api_key}"; |
||
| 154 | |||
| 155 | $response = json_decode(file_get_contents($api_url), true); |
||
| 156 | |||
| 157 | if (isset($response['items'])) { |
||
| 158 | if ($this->dates_only === true) { |
||
| 159 | foreach ($response['items'] as $holiday) { |
||
| 160 | $result[] = $holiday['start']['date']; |
||
| 161 | } |
||
| 162 | |||
| 163 | sort($result); |
||
| 164 | } elseif ($this->minimal === true) { |
||
| 165 | foreach ($response['items'] as $holiday) { |
||
| 166 | $result[] = [ |
||
| 167 | 'name' => $holiday['summary'], |
||
| 168 | 'date' => $holiday['start']['date'], |
||
| 169 | ]; |
||
| 170 | } |
||
| 171 | |||
| 172 | usort($result, function ($a, $b) { |
||
| 173 | if ($a['date'] == $b['date']) { |
||
| 174 | return 0; |
||
| 175 | } |
||
| 176 | |||
| 177 | return ($a['date'] < $b['date']) ? -1 : 1; |
||
| 178 | }); |
||
| 179 | } else { |
||
| 180 | $result = $response['items']; |
||
| 181 | |||
| 182 | usort($result, function ($a, $b) { |
||
| 183 | if ($a['start']['date'] == $b['start']['date']) { |
||
| 184 | return 0; |
||
| 185 | } |
||
| 186 | |||
| 187 | return ($a['start']['date'] < $b['start']['date']) ? -1 : 1; |
||
| 188 | }); |
||
| 189 | } |
||
| 190 | } |
||
| 191 | |||
| 192 | return $result; |
||
| 193 | } |
||
| 195 |
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