Passed
Push — master ( 73a53e...f91dab )
by Bruno
07:25 queued 04:03
created

processModelRelationshipDirective()   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 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 7
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 3
crap 2
1
<?php declare(strict_types=1);
2
3
namespace Modelarium\Laravel\Directives;
4
5
use Illuminate\Support\Str;
6
use Modelarium\Exception\DirectiveException;
7
use Modelarium\Laravel\Targets\MigrationGenerator;
8
use Modelarium\Laravel\Targets\ModelGenerator;
9
use Modelarium\Laravel\Targets\Interfaces\MigrationDirectiveInterface;
10
use Modelarium\Laravel\Targets\Interfaces\ModelDirectiveInterface;
11
use Modelarium\Laravel\Targets\MigrationCodeFragment;
12
13
class MigrationSoftDeletesDirective implements MigrationDirectiveInterface, ModelDirectiveInterface
14
{
15 3
    public static function processMigrationTypeDirective(
16
        MigrationGenerator $generator,
17
        \GraphQL\Language\AST\DirectiveNode $directive
18
    ): void {
19 3
        $generator->createCode[] ='$table->softDeletes();';
20 3
    }
21
22
    public static function processMigrationFieldDirective(
23
        MigrationGenerator $generator,
24
        \GraphQL\Type\Definition\FieldDefinition $field,
25
        \GraphQL\Language\AST\DirectiveNode $directive,
26
        MigrationCodeFragment $code
27
    ): void {
28
        throw new DirectiveException("Directive not supported here");
29
    }
30
31
    public static function processMigrationRelationshipDirective(
32
        MigrationGenerator $generator,
33
        \GraphQL\Type\Definition\FieldDefinition $field,
34
        \GraphQL\Language\AST\DirectiveNode $directive,
35
        MigrationCodeFragment $code
36
    ): void {
37
        throw new DirectiveException("Directive not supported here");
38
    }
39
40 1
    public static function processModelTypeDirective(
41
        ModelGenerator $generator,
42
        \GraphQL\Language\AST\DirectiveNode $directive
43
    ): void {
44 1
        $generator->traits[] = '\Illuminate\Database\Eloquent\SoftDeletes';
45 1
    }
46
47
    public static function processModelFieldDirective(
48
        ModelGenerator $generator,
49
        \GraphQL\Type\Definition\FieldDefinition $field,
50
        \Formularium\Field $fieldFormularium,
51
        \GraphQL\Language\AST\DirectiveNode $directive
52
    ): void {
53
        // nothing
54
    }
55
56
    public static function processModelRelationshipDirective(
57
        ModelGenerator $generator,
58
        \GraphQL\Type\Definition\FieldDefinition $field,
59
        \GraphQL\Language\AST\DirectiveNode $directive
60
    ): string {
61
        // nothing
62
        return '';
63
    }
64
}
65