Conditions | 7 |
Paths | 7 |
Total Lines | 52 |
Code Lines | 36 |
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 |
||
77 | public function generateSimpleProviders() |
||
78 | { |
||
79 | $response = file_get_contents('https://oembed.com/providers.json'); |
||
80 | |||
81 | if (!$response) { |
||
82 | throw new Exception('Error reteriving providers list.'); |
||
83 | } |
||
84 | |||
85 | $providers = json_decode($response, true); |
||
86 | |||
87 | $providerFormat = <<<END |
||
88 | '%s' => [ |
||
89 | 'schemes' => [ |
||
90 | %s |
||
91 | ] |
||
92 | ], |
||
93 | |||
94 | END; |
||
95 | |||
96 | $schemeFormat = <<<END |
||
97 | '%s', |
||
98 | END; |
||
99 | |||
100 | $formattedProviders = ''; |
||
101 | foreach ($providers as $provider) { |
||
102 | foreach ($provider['endpoints'] as $endpoint) { |
||
103 | if (!isset($endpoint['schemes'])) { |
||
104 | continue; |
||
105 | } |
||
106 | |||
107 | $schemes = ''; |
||
108 | $url = str_replace('.{format}', '.json', $endpoint['url']); |
||
109 | $url = str_replace('?format={format}', '?format=json', $url); |
||
110 | foreach ($endpoint['schemes'] as $skey => $url) { |
||
111 | $scheme = '|^' . $url; |
||
112 | $scheme = preg_replace('/([.=?#-])/i', '\\\\\\\\${1}', $scheme); |
||
113 | $scheme = str_replace('http:', 'https?:', $scheme); |
||
114 | $scheme = str_replace('https:', 'https?:', $scheme); |
||
115 | $scheme = str_replace('*', '.*', $scheme); |
||
116 | $scheme .= '$|i'; |
||
117 | $schemes .= ($skey > 0 ? "\n " : "") . sprintf($schemeFormat, $scheme); |
||
118 | } |
||
119 | |||
120 | $formattedProviders .= sprintf( |
||
121 | $providerFormat, |
||
122 | $endpoint['url'], |
||
123 | $schemes |
||
124 | ); |
||
125 | } |
||
126 | } |
||
127 | |||
128 | file_put_contents('simple_providers.txt', $formattedProviders); |
||
129 | } |
||
134 |
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