| Conditions | 11 |
| Paths | 32 |
| Total Lines | 51 |
| Code Lines | 39 |
| 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 |
||
| 62 | public function readData($option): array |
||
| 63 | { |
||
| 64 | $http_code = ''; |
||
| 65 | if (isset($option['link'])) $string = 'https://api.github.com/repos/' . $option['link'] . '/releases'; |
||
| 66 | else $string = 'https://api.github.com/repos/' . $option['user'] . '/' . $option['repository'] . '/releases'; |
||
| 67 | |||
| 68 | $ch = curl_init(); |
||
| 69 | if ($ch !== false) { |
||
| 70 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); |
||
| 71 | curl_setopt($ch, CURLOPT_HEADER, false); |
||
| 72 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
||
| 73 | curl_setopt($ch, CURLOPT_URL, $string); |
||
| 74 | curl_setopt($ch, CURLOPT_REFERER, $string); |
||
| 75 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); |
||
| 76 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); |
||
| 77 | $curlResult = curl_exec($ch); |
||
| 78 | $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
||
| 79 | curl_close($ch); |
||
| 80 | } else { |
||
| 81 | $curlResult = ''; |
||
| 82 | } |
||
| 83 | |||
| 84 | $json = json_decode($curlResult, true); |
||
| 85 | $i = 0; |
||
| 86 | $data = array(); |
||
| 87 | foreach ($json as $item) { |
||
| 88 | if (isset($option['limit']) and $option['limit'] !== '') { |
||
| 89 | if ($i === (int)$option['limit']) break; |
||
| 90 | } |
||
| 91 | $nc_value = 0; |
||
| 92 | foreach ($item['assets'] as $asset) { |
||
| 93 | if (str_ends_with($asset['name'], 'gz')) $nc_value = $asset['download_count']; |
||
| 94 | } |
||
| 95 | $data[] = [$item['tag_name'], $this->floatvalue($nc_value)]; |
||
| 96 | $i++; |
||
| 97 | } |
||
| 98 | |||
| 99 | $header = array(); |
||
| 100 | $header[0] = $this->l10n->t('Version'); |
||
| 101 | $header[1] = $this->l10n->t('Download count'); |
||
| 102 | |||
| 103 | usort($data, function ($a, $b) { |
||
| 104 | return strnatcmp($a[0], $b[0]); |
||
| 105 | }); |
||
| 106 | |||
| 107 | return [ |
||
| 108 | 'header' => $header, |
||
| 109 | 'dimensions' => array_slice($header, 0, count($header) - 1), |
||
| 110 | 'data' => $data, |
||
| 111 | 'rawdata' => $curlResult, |
||
| 112 | 'error' => ($http_code>=200 && $http_code<300) ? 0 : 'HTTP response code: '.$http_code, |
||
| 113 | ]; |
||
| 127 | } |
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