processModelRelationshipDirective()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 4
dl 0
loc 7
ccs 0
cts 2
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Modelarium\Laravel\Directives;
4
5
use GraphQL\Language\AST\DirectiveNode;
6
use Modelarium\Laravel\Targets\ModelGenerator;
7
use Modelarium\Laravel\Targets\Interfaces\ModelDirectiveInterface;
8
9
class CastsDirective implements ModelDirectiveInterface
10
{
11
    public static function processModelTypeDirective(
12
        ModelGenerator $generator,
13
        \GraphQL\Language\AST\DirectiveNode $directive
14
    ): void {
15
    }
16
17
    public static function processModelFieldDirective(
18
        ModelGenerator $generator,
19
        \GraphQL\Type\Definition\FieldDefinition $field,
20
       \Formularium\Field $fieldFormularium,
21
        \GraphQL\Language\AST\DirectiveNode $directive
22
    ): void {
23
        $fieldName = $field->name;
24
        foreach ($directive->arguments as $arg) {
25
            /**
26
             * @var \GraphQL\Language\AST\ArgumentNode $arg
27
             */
28
            /** @phpstan-ignore-next-line */
29
            $value = $arg->value->value;
30
31
            switch ($arg->name->value) {
32
            case 'type':
33
                $generator->casts[$fieldName] = $value;
34
            }
35
        }
36
    }
37
38
    public static function processModelRelationshipDirective(
39
        ModelGenerator $generator,
40
        \GraphQL\Type\Definition\FieldDefinition $field,
41
        \GraphQL\Language\AST\DirectiveNode $directive,
42
        \Formularium\Datatype $datatype = null
43
    ): ?\Formularium\Datatype {
44
        return null;
45
    }
46
}
47