| Conditions | 2 |
| Paths | 1 |
| Total Lines | 52 |
| Code Lines | 33 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 25 | public function getMatchers(): array |
||
| 26 | { |
||
| 27 | return [ |
||
| 28 | 'beInJson' => function ($subject) { |
||
| 29 | Assert::isInstanceOf($subject, JsonResponse::class); |
||
| 30 | |||
| 31 | return true; |
||
| 32 | }, |
||
| 33 | 'containJsonKey' => function ($subject, $key) { |
||
| 34 | /** @var \Symfony\Component\HttpFoundation\JsonResponse $subject */ |
||
| 35 | $json = $subject->getContent(); |
||
| 36 | $json = json_decode($json, true); |
||
| 37 | Assert::isArray($json); |
||
| 38 | Assert::keyExists($json, $key); |
||
| 39 | |||
| 40 | return true; |
||
| 41 | }, |
||
| 42 | 'containJsonKeyWithValue' => function ($subject, $key, $expected) { |
||
| 43 | /** @var \Symfony\Component\HttpFoundation\JsonResponse $subject */ |
||
| 44 | $json = $subject->getContent(); |
||
| 45 | $json = json_decode($json, true); |
||
| 46 | Assert::keyExists($json, $key); |
||
| 47 | Assert::contains($json[$key], $expected); |
||
| 48 | |||
| 49 | return true; |
||
| 50 | }, |
||
| 51 | 'haveStatusCode' => function ($subject, $expected) { |
||
| 52 | Assert::eq($subject->getStatusCode(), $expected); |
||
| 53 | |||
| 54 | return true; |
||
| 55 | }, |
||
| 56 | 'haveContent' => function ($subject, $expected) { |
||
| 57 | Assert::isInstanceOf($subject, Response::class); |
||
| 58 | Assert::contains($subject->getContent(), $expected); |
||
| 59 | |||
| 60 | return true; |
||
| 61 | }, |
||
| 62 | 'beAHttpResponse' => function ($subject) { |
||
| 63 | Assert::isInstanceOf($subject, Response::class); |
||
| 64 | |||
| 65 | return true; |
||
| 66 | }, |
||
| 67 | 'beASerializedObject' => function ($subject, $expected) { |
||
| 68 | /** @var \Symfony\Component\HttpFoundation\Response $subject */ |
||
| 69 | $serialized = unserialize($subject->getContent()); |
||
| 70 | $class = $expected; |
||
| 71 | if (!\is_string($class)) { |
||
| 72 | $class = \get_class($class); |
||
| 73 | } |
||
| 74 | Assert::isInstanceOf($serialized, $class); |
||
| 75 | |||
| 76 | return true; |
||
| 77 | }, |
||
| 81 |
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