| Conditions | 12 |
| Paths | 28 |
| Total Lines | 61 |
| Code Lines | 29 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 71 | public static function request($uri, $dataProviderParams = []) |
||
| 72 | { |
||
| 73 | $curl = new \Curl\Curl(); |
||
| 74 | $redirects_count = 0; |
||
| 75 | |||
| 76 | // base URI reference |
||
| 77 | if (!self::$url_reference){ |
||
| 78 | throw new CittaException('URI Reference Error'); |
||
| 79 | } |
||
| 80 | |||
| 81 | // consult URI |
||
| 82 | if (is_array($uri)){ |
||
| 83 | $curl->get(self::$url_reference.\yii\helpers\Url::to($uri)); |
||
| 84 | |||
| 85 | } else if (is_string($uri)){ |
||
| 86 | $curl->get(self::$url_reference."/{$uri}"); |
||
| 87 | |||
| 88 | } else { |
||
| 89 | throw new CittaException('URI Type Error'); |
||
| 90 | } |
||
| 91 | |||
| 92 | |||
| 93 | // redirect URI |
||
| 94 | while (300 <= $curl->http_status_code && $curl->http_status_code < 400){ |
||
| 95 | // probably loop |
||
| 96 | if (++$redirects_count > 10){ |
||
| 97 | throw new CittaException('Too many redirects'); |
||
| 98 | } |
||
| 99 | |||
| 100 | foreach ($curl->response_headers as $header) { |
||
| 101 | // ignore header |
||
| 102 | if (strpos($header, 'Location:') === false){ |
||
| 103 | continue; |
||
| 104 | } |
||
| 105 | |||
| 106 | // try new uri |
||
| 107 | $curl->get(strtr($header,[ |
||
| 108 | 'Location: ' => '', |
||
| 109 | 'location: ' => '', |
||
| 110 | 'Location:' => '', |
||
| 111 | 'location:' => '' |
||
| 112 | ]) |
||
| 113 | ); |
||
| 114 | } |
||
| 115 | } |
||
| 116 | |||
| 117 | // resquest error |
||
| 118 | if ($curl->error && $curl->http_status_code){ |
||
| 119 | throw new CittaException("HTTP Status {$curl->http_status_code} Error"); |
||
| 120 | } |
||
| 121 | |||
| 122 | // curl error |
||
| 123 | if ($curl->error){ |
||
| 124 | throw new CittaException($curl->error_message); |
||
| 125 | } |
||
| 126 | |||
| 127 | // return response data |
||
| 128 | return new \yii\data\ArrayDataProvider( |
||
| 129 | \yii\Helpers\ArrayHelper::merge( |
||
| 130 | ['allModels' => \yii\helpers\Json::decode($curl->response, true)], |
||
| 131 | $dataProviderParams |
||
| 132 | ) |
||
| 135 | } |
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