| Total Complexity | 6 |
| Total Lines | 44 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 18 | final class JsonSchemaExceptionFakeHandler implements JsonSchemaExceptionHandlerInterface |
||
| 19 | { |
||
| 20 | final public const X_FAKE_JSON = 'X-Fake-JSON'; |
||
| 21 | final public const X_JSON_SCHEMA_EXCEPTION = 'X-JSON-Schema-Exception'; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * {@inheritDoc} |
||
| 25 | */ |
||
| 26 | #[Override] |
||
| 27 | public function handle(ResourceObject $ro, JsonSchemaException $e, string $schemaFile) |
||
| 28 | { |
||
| 29 | $ro->headers[self::X_FAKE_JSON] = $schemaFile; |
||
| 30 | $ro->headers[self::X_JSON_SCHEMA_EXCEPTION] = $e->getMessage(); |
||
| 31 | $ro->body = $this->fakeResponse($schemaFile); |
||
| 32 | $ro->view = null; |
||
| 33 | } |
||
| 34 | |||
| 35 | /** @return Body */ |
||
|
|
|||
| 36 | private function fakeResponse(string $schemaFile): array |
||
| 37 | { |
||
| 38 | if (! class_exists(Faker::class)) { |
||
| 39 | throw new LogicException('"koriym/json-schema-faker" not installed. Please run "composer require koriym/json-schema-faker --dev". See more at https://github.com/bearsunday/BEAR.Resource/wiki/json_schema_faker_required'); // @codeCoverageIgnore |
||
| 40 | } |
||
| 41 | |||
| 42 | /** @var Body $fakeObject */ |
||
| 43 | $fakeObject = (new Faker())->generate(new SplFileInfo($schemaFile)); |
||
| 44 | |||
| 45 | return $this->deepArray($fakeObject); |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param Body $values |
||
| 50 | * |
||
| 51 | * @return Body |
||
| 52 | */ |
||
| 53 | private function deepArray(array|stdClass $values): array |
||
| 62 | } |
||
| 63 | } |
||
| 64 |
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