Conditions | 8 |
Paths | 10 |
Total Lines | 66 |
Code Lines | 49 |
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 |
||
9 | public function generateProviders() |
||
10 | { |
||
11 | $response = file_get_contents('https://oembed.com/providers.json'); |
||
12 | |||
13 | if (!$response) { |
||
14 | throw new Exception('Error reteriving providers list.'); |
||
15 | } |
||
16 | |||
17 | $providers = json_decode($response, true); |
||
18 | |||
19 | $providerFormat = <<<END |
||
20 | [ |
||
21 | 'provider_name' => '%s', |
||
22 | 'provider_url' => '%s', |
||
23 | 'endpoints' => [ |
||
24 | %s |
||
25 | ] |
||
26 | ], |
||
27 | |||
28 | END; |
||
29 | |||
30 | $endpointFormat = <<<END |
||
31 | [ |
||
32 | 'schemes' => [ |
||
33 | %s |
||
34 | ], |
||
35 | 'url' => '%s', |
||
36 | ], |
||
37 | END; |
||
38 | |||
39 | $schemeFormat = <<<END |
||
40 | '%s', |
||
41 | END; |
||
42 | |||
43 | $formattedProviders = ''; |
||
44 | foreach ($providers as $provider) { |
||
45 | $endpoints = ''; |
||
46 | foreach ($provider['endpoints'] as $ekey => $endpoint) { |
||
47 | if (!isset($endpoint['schemes'])) { |
||
48 | continue; |
||
49 | } |
||
50 | |||
51 | $schemes = ''; |
||
52 | $url = str_replace('.{format}', '.json', $endpoint['url']); |
||
53 | $url = str_replace('?format={format}', '?format=json', $url); |
||
54 | foreach ($endpoint['schemes'] as $skey => $url) { |
||
55 | $scheme = '|^' . $url; |
||
56 | $scheme = preg_replace('/([.=?#-])/i', '\\\\\\\\${1}', $scheme); |
||
57 | $scheme = str_replace('http:', 'https?:', $scheme); |
||
58 | $scheme = str_replace('https:', 'https?:', $scheme); |
||
59 | $scheme = str_replace('*', '.*', $scheme); |
||
60 | $scheme .= '$|i'; |
||
61 | $schemes .= ($skey > 0 ? "\n " : "") . sprintf($schemeFormat, $scheme); |
||
62 | } |
||
63 | $endpoints .= ($ekey > 0 ? "\n " : "") . sprintf($endpointFormat, $schemes, $endpoint['url']); |
||
64 | } |
||
65 | |||
66 | $formattedProviders .= sprintf( |
||
67 | $providerFormat, |
||
68 | $provider['provider_name'], |
||
69 | $provider['provider_url'], |
||
70 | $endpoints |
||
71 | ); |
||
72 | } |
||
73 | |||
74 | file_put_contents('providers.txt', $formattedProviders); |
||
75 | } |
||
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