Passed
Push — master ( 8dade9...95b6b2 )
by Bruno
10:05
created

MigrationDefaultValueDirective   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A processMigrationTypeDirective() 0 4 1
A processMigrationFieldDirective() 0 8 1
1
<?php declare(strict_types=1);
2
3
namespace Modelarium\Laravel\Directives;
4
5
use Modelarium\Laravel\Targets\MigrationGenerator;
6
use Modelarium\Laravel\Targets\Interfaces\MigrationDirectiveInterface;
7
use Modelarium\Laravel\Targets\MigrationCodeFragment;
8
use Modelarium\Parser;
9
10
class MigrationDefaultValueDirective implements MigrationDirectiveInterface
11
{
12
    public static function processMigrationTypeDirective(
13
        MigrationGenerator $generator,
14
        \GraphQL\Language\AST\DirectiveNode $directive
15
    ): void {
16
        // nothing
17
    }
18
19
    public static function processMigrationFieldDirective(
20
        MigrationGenerator $generator,
21
        \GraphQL\Type\Definition\FieldDefinition $field,
22
        \GraphQL\Language\AST\DirectiveNode $directive,
23
        MigrationCodeFragment $code
24
    ): void {
25
        $x = Parser::getDirectiveArgumentByName($directive, 'value');
26
        $code->appendBase('->default(' . $x . ')');
27
    }
28
}
29