| Conditions | 7 |
| Paths | 31 |
| Total Lines | 56 |
| Code Lines | 41 |
| 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 |
||
| 36 | public function run(): array |
||
| 37 | { |
||
| 38 | $methods = array_filter(get_class_methods($this), static function (string $method): bool { |
||
| 39 | return 0 === strpos($method, 'test'); |
||
| 40 | }); |
||
| 41 | sort($methods); |
||
| 42 | |||
| 43 | $failures = []; |
||
| 44 | $errors = []; |
||
| 45 | $details = []; |
||
| 46 | |||
| 47 | foreach ($methods as $method) { |
||
| 48 | $status = 'passed'; |
||
| 49 | $message = ''; |
||
| 50 | $exception = null; |
||
| 51 | |||
| 52 | try { |
||
| 53 | $this->setUp(); |
||
| 54 | $this->$method(); |
||
| 55 | } catch (AssertionFailedError $failure) { |
||
| 56 | $status = 'failure'; |
||
| 57 | $message = $failure->getMessage(); |
||
| 58 | $exception = $failure; |
||
| 59 | } catch (Throwable $throwable) { |
||
| 60 | $status = 'error'; |
||
| 61 | $message = $throwable->getMessage(); |
||
| 62 | $exception = $throwable; |
||
| 63 | } |
||
| 64 | |||
| 65 | try { |
||
| 66 | $this->tearDown(); |
||
| 67 | } catch (Throwable $teardown) { |
||
| 68 | $status = 'error'; |
||
| 69 | $message = 'tearDown failure: ' . $teardown->getMessage(); |
||
| 70 | $exception = $teardown; |
||
| 71 | } |
||
| 72 | |||
| 73 | if ('failure' === $status) { |
||
| 74 | $failures[] = ['test' => $method, 'message' => $message, 'exception' => $exception]; |
||
| 75 | } elseif ('error' === $status) { |
||
| 76 | $errors[] = ['test' => $method, 'message' => $message, 'exception' => $exception]; |
||
| 77 | } |
||
| 78 | |||
| 79 | $details[] = ['test' => $method, 'status' => $status, 'message' => $message]; |
||
| 80 | } |
||
| 81 | |||
| 82 | $count = count($methods); |
||
| 83 | $passed = $count - count($failures) - count($errors); |
||
| 84 | |||
| 85 | return [ |
||
| 86 | 'class' => static::class, |
||
| 87 | 'count' => $count, |
||
| 88 | 'passed' => $passed, |
||
| 89 | 'failures' => $failures, |
||
| 90 | 'errors' => $errors, |
||
| 91 | 'details' => $details, |
||
| 92 | ]; |
||
| 161 |
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