Passed
Push — master ( 6bf22a...09030e )
by Bruno
04:28
created

processMigrationRelationshipDirective()   A

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 1 Features 1
Metric Value
cc 1
eloc 1
c 1
b 1
f 1
nc 1
nop 4
dl 0
loc 7
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Modelarium\Laravel\Directives;
4
5
use Modelarium\Exception\DirectiveException;
6
use Modelarium\Exception\Exception;
7
use Modelarium\Laravel\Targets\MigrationGenerator;
8
use Modelarium\Laravel\Targets\Interfaces\MigrationDirectiveInterface;
9
use Modelarium\Laravel\Targets\MigrationCodeFragment;
10
use Modelarium\Parser;
11
12
class MigrationAlterTableDirective implements MigrationDirectiveInterface
13
{
14 1
    public static function processMigrationTypeDirective(
15
        MigrationGenerator $generator,
16
        \GraphQL\Language\AST\DirectiveNode $directive
17
    ): void {
18 1
        $values = Parser::getDirectiveArgumentByName($directive, 'values');
19
20 1
        foreach ($values as $v) {
21 1
            $generator->postCreateCode[] = "DB::statement('ALTER TABLE " .
22 1
                $generator->getTableName() . ' ' .
23 1
                $v .
24 1
                "');";
25
        }
26 1
    }
27
28
    public static function processMigrationFieldDirective(
29
        MigrationGenerator $generator,
30
        \GraphQL\Type\Definition\FieldDefinition $field,
31
        \GraphQL\Language\AST\DirectiveNode $directive,
32
        MigrationCodeFragment $code
33
    ): void {
34
        throw new DirectiveException("migrationAlterTable only applies to type");
35
    }
36
37
    public static function processMigrationRelationshipDirective(
38
        MigrationGenerator $generator,
39
        \GraphQL\Type\Definition\FieldDefinition $field,
40
        \GraphQL\Language\AST\DirectiveNode $directive,
41
        MigrationCodeFragment $code
42
    ): void {
43
        throw new DirectiveException("migrationAlterTable only applies to type");
44
    }
45
}
46