| Conditions | 10 |
| Paths | 12 |
| Total Lines | 25 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 110 |
| 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 |
||
| 29 | protected function assertPostTypeOnQuery(WP_Query $query, string $postType): self |
||
| 30 | { |
||
| 31 | $actual = $query->get('post_type') |
||
| 32 | ?: $query->get_queried_object()->post_type |
||
| 33 | ?? $postType; |
||
| 34 | |||
| 35 | if (is_array($actual) && count($actual) === 1) { |
||
| 36 | $actual = $actual[0]; |
||
| 37 | } elseif (!is_string($actual)) { |
||
| 38 | $actual = null; |
||
| 39 | } |
||
| 40 | |||
| 41 | if ($postType !== $actual) { |
||
| 42 | if (is_string($actual) || $actual instanceof Stringable) { |
||
| 43 | $message = "Query post_type value must be \"{$postType}\", but it is \"{$actual}\"."; |
||
| 44 | } elseif (is_array($actual) && in_array($postType, $actual, true)) { |
||
| 45 | $message = "post_type value for query must be exclusively for \"{$postType}\"."; |
||
| 46 | } else { |
||
| 47 | $message = "Query post_type value must be \"{$postType}\"."; |
||
| 48 | } |
||
| 49 | |||
| 50 | throw new InvalidArgumentException($message); |
||
| 51 | } |
||
| 52 | |||
| 53 | return $this; |
||
| 54 | } |
||
| 56 |
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