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

processMigrationFieldDirective()   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
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\Exception\DirectiveException;
6
use Modelarium\Exception\Exception;
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 MigrationSpatialIndexDirective implements MigrationDirectiveInterface, ModelDirectiveInterface
14
{
15 1
    public static function processMigrationTypeDirective(
16
        MigrationGenerator $generator,
17
        \GraphQL\Language\AST\DirectiveNode $directive
18
    ): void {
19
        /** @phpstan-ignore-next-line */
20 1
        $generator->createCode[] = '$table->spatialIndex("' . $directive->arguments[0]->value->value .'");';
0 ignored issues
show
Bug introduced by
Accessing value on the interface GraphQL\Language\AST\ValueNode suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
21 1
    }
22
23
    public static function processMigrationFieldDirective(
24
        MigrationGenerator $generator,
25
        \GraphQL\Type\Definition\FieldDefinition $field,
26
        \GraphQL\Language\AST\DirectiveNode $directive,
27
        MigrationCodeFragment $code
28
    ): void {
29
        throw new DirectiveException("Directive not supported here");
30
    }
31
32
    public static function processMigrationRelationshipDirective(
33
        MigrationGenerator $generator,
34
        \GraphQL\Type\Definition\FieldDefinition $field,
35
        \GraphQL\Language\AST\DirectiveNode $directive,
36
        MigrationCodeFragment $code
37
    ): void {
38
        throw new DirectiveException("Directive not supported here");
39
    }
40
41
    public static function processModelTypeDirective(
42
        ModelGenerator $generator,
43
        \GraphQL\Language\AST\DirectiveNode $directive
44
    ): void {
45
        throw new Exception("Spatial index is not implemented yet");
46
    }
47
48
    public static function processModelFieldDirective(
49
        ModelGenerator $generator,
50
        \GraphQL\Type\Definition\FieldDefinition $field,
51
        \Formularium\Field $fieldFormularium,
52
        \GraphQL\Language\AST\DirectiveNode $directive
53
    ): void {
54
        // nothing
55
    }
56
57
    public static function processModelRelationshipDirective(
58
        ModelGenerator $generator,
59
        \GraphQL\Type\Definition\FieldDefinition $field,
60
        \GraphQL\Language\AST\DirectiveNode $directive
61
    ): string {
62
        // nothing
63
        return '';
64
    }
65
}
66