ApiResourceLinkSchemaBuilder   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 30
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 15 3
A __construct() 0 3 1
1
<?php
2
3
4
namespace Apie\PrimaryKeyPlugin\Schema;
5
6
use Apie\Core\PluginInterfaces\DynamicSchemaInterface;
7
use Apie\Core\PluginInterfaces\FrameworkConnectionInterface;
8
use Apie\OpenapiSchema\Factories\SchemaFactory;
9
use W2w\Lib\Apie\OpenApiSchema\OpenApiSchemaGenerator;
0 ignored issues
show
Bug introduced by
The type W2w\Lib\Apie\OpenApiSchema\OpenApiSchemaGenerator was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
11
class ApiResourceLinkSchemaBuilder implements DynamicSchemaInterface
12
{
13
    /**
14
     * @var FrameworkConnectionInterface
15
     */
16
    private $connection;
17
18
    public function __construct(FrameworkConnectionInterface $connection)
19
    {
20
        $this->connection = $connection;
21
    }
22
23
    /**
24
     * {@inheritDoc}
25
     */
26
    public function __invoke(
27
        string $resourceClass,
28
        string $operation,
29
        array $groups,
30
        int $recursion,
31
        OpenApiSchemaGenerator $generator
32
    ): ?Schema {
0 ignored issues
show
Bug introduced by
The type Apie\PrimaryKeyPlugin\Schema\Schema was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
33
        if ($recursion > 0 && $operation === 'get') {
34
            return SchemaFactory::createStringSchema(
0 ignored issues
show
Bug Best Practice introduced by
The expression return Apie\OpenapiSchem...($resourceClass), true) returns the type Apie\OpenapiSchema\Spec\Schema which is incompatible with the type-hinted return Apie\PrimaryKeyPlugin\Schema\Schema|null.
Loading history...
35
                'path',
36
                $this->connection->getExampleUrl($resourceClass),
37
                true
38
            );
39
        }
40
        return $generator->createSchema($resourceClass, $operation, $groups);
41
    }
42
}
43