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 Modelarium\Datatype\Datatype_relationship;
6
use Modelarium\Laravel\Targets\ModelGenerator;
7
use Modelarium\Laravel\Targets\Interfaces\ModelDirectiveInterface;
8
9
class ModelFillableDirective 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
        if ($fieldFormularium->getDatatype() instanceof Datatype_relationship) {
25
            $generator->fillable[] = $fieldName . '_id';
26
        } else {
27
            $generator->fillable[] = $fieldName;
28
        }
29
    }
30
31
    public static function processModelRelationshipDirective(
32
        ModelGenerator $generator,
33
        \GraphQL\Type\Definition\FieldDefinition $field,
34
        \GraphQL\Language\AST\DirectiveNode $directive,
35
        \Formularium\Datatype $datatype = null
36
    ): ?\Formularium\Datatype {
37
        return null;
38
    }
39
}
40