Passed
Branch 3.3 (6947f9)
by Pieter
03:45
created

ApiResourceLinkSchemaBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 24
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 14 3
1
<?php
2
3
4
namespace W2w\Lib\Apie\Plugins\PrimaryKey\Schema;
5
6
7
use erasys\OpenApi\Spec\v3\Schema;
8
use W2w\Lib\Apie\OpenApiSchema\SchemaGenerator;
9
use W2w\Lib\Apie\PluginInterfaces\DynamicSchemaInterface;
10
11
class ApiResourceLinkSchemaBuilder implements DynamicSchemaInterface
12
{
13
14
    /**
15
     * @param string $resourceClass
16
     * @param string $operation
17
     * @param array $groups
18
     * @param int $recursion
19
     * @param SchemaGenerator $generator
20
     */
21
    public function __invoke(
22
        string $resourceClass,
23
        string $operation,
24
        array $groups,
25
        int $recursion,
26
        SchemaGenerator $generator
27
    ) {
28
        if ($recursion > 0 && $operation === 'get') {
29
            return new Schema([
30
                'type' => 'string',
31
                'format' => 'path',
32
            ]);
33
        }
34
        return $generator->createSchema($resourceClass, $operation, $groups);
35
    }
36
}
37