| Conditions | 13 |
| Paths | 16 |
| Total Lines | 55 |
| Code Lines | 37 |
| 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 | $policyIsSet = false; |
||
| 67 | |||
| 68 | if (count($values) > 0) { |
||
| 69 | foreach ($values as $value) { |
||
| 70 | switch ($value) { |
||
| 71 | case 'none': |
||
| 72 | case 'self': |
||
| 73 | case 'strict-dynamic': |
||
| 74 | $policyIsSet = true; |
||
| 75 | $constructedPolicy .= "'{$value}' "; |
||
| 76 | break; |
||
| 77 | case 'nonce': |
||
| 78 | if ($this->nonce !== null) { |
||
| 79 | $policyIsSet = true; |
||
| 80 | $constructedPolicy .= "'nonce-{$this->nonce}' "; |
||
| 81 | } |
||
| 82 | break; |
||
| 83 | case 'oauth': |
||
| 84 | $policyIsSet = true; |
||
| 85 | $constructedPolicy .= "{$this->configuration->getOauthMediaWikiCanonicalServer()} "; |
||
| 86 | break; |
||
| 87 | default: |
||
| 88 | $policyIsSet = true; |
||
| 89 | $constructedPolicy .= $value . ' '; |
||
| 90 | break; |
||
| 91 | } |
||
| 92 | } |
||
| 93 | |||
| 94 | if (!$policyIsSet) { |
||
| 95 | $constructedPolicy .= "'none' "; |
||
| 96 | } |
||
| 97 | } |
||
| 98 | else { |
||
| 99 | $constructedPolicy .= "'none' "; |
||
| 100 | } |
||
| 101 | |||
| 102 | $constructedPolicy .= '; '; |
||
| 103 | } |
||
| 104 | |||
| 105 | if ($this->configuration->getCspReportUri() !== null) { |
||
| 106 | $constructedPolicy .= 'report-uri ' . $this->configuration->getCspReportUri(); |
||
| 107 | } |
||
| 108 | |||
| 109 | return $constructedPolicy; |
||
| 110 | } |
||
| 112 |
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