Conditions | 12 |
Paths | 12 |
Total Lines | 46 |
Code Lines | 30 |
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 |
||
55 | public function getHeader(): string |
||
56 | { |
||
57 | $reportOnly = ''; |
||
58 | if ($this->reportOnly) { |
||
59 | $reportOnly = '-Report-Only'; |
||
60 | } |
||
61 | |||
62 | $constructedPolicy = "Content-Security-Policy{$reportOnly}: "; |
||
63 | |||
64 | foreach ($this->policy as $item => $values) { |
||
65 | $constructedPolicy .= $item . ' '; |
||
66 | |||
67 | if (count($values) > 0) { |
||
68 | foreach ($values as $value) { |
||
69 | switch ($value) { |
||
70 | case 'none': |
||
71 | case 'self': |
||
72 | case 'strict-dynamic': |
||
73 | $constructedPolicy .= "'{$value}' "; |
||
74 | break; |
||
75 | case 'nonce': |
||
76 | if ($this->nonce !== null) { |
||
77 | $constructedPolicy .= "'nonce-{$this->nonce}' "; |
||
78 | } |
||
79 | break; |
||
80 | case 'oauth': |
||
81 | $constructedPolicy .= "{$this->configuration->getOauthMediaWikiCanonicalServer()} "; |
||
82 | break; |
||
83 | default: |
||
84 | $constructedPolicy .= $value . ' '; |
||
85 | break; |
||
86 | } |
||
87 | } |
||
88 | } |
||
89 | else { |
||
90 | $constructedPolicy .= "'none' "; |
||
91 | } |
||
92 | |||
93 | $constructedPolicy .= '; '; |
||
94 | } |
||
95 | |||
96 | if ($this->configuration->getCspReportUri() !== null) { |
||
97 | $constructedPolicy .= 'report-uri ' . $this->configuration->getCspReportUri(); |
||
98 | } |
||
99 | |||
100 | return $constructedPolicy; |
||
101 | } |
||
103 |
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