Passed
Push — master ( f71ccb...0ebae0 )
by Bruno
03:45
created

processMigrationFieldDirective()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 0
c 1
b 0
f 0
dl 0
loc 5
ccs 0
cts 1
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 Modelarium\Exception\Exception;
6
use Modelarium\Laravel\Targets\MigrationGenerator;
7
use Modelarium\Laravel\Targets\ModelGenerator;
8
use Modelarium\Laravel\Targets\Interfaces\MigrationDirectiveInterface;
9
use Modelarium\Laravel\Targets\Interfaces\ModelDirectiveInterface;
10
11
class MigrationSpatialIndexDirective implements MigrationDirectiveInterface, ModelDirectiveInterface
12
{
13 1
    public static function processMigrationTypeDirective(
14
        MigrationGenerator $generator,
15
        \GraphQL\Language\AST\DirectiveNode $directive
16
    ): void {
17
        /** @phpstan-ignore-next-line */
18 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...
19 1
    }
20
21
    public static function processMigrationFieldDirective(
22
        MigrationGenerator $generator,
23
        \GraphQL\Type\Definition\FieldDefinition $field,
24
        \GraphQL\Language\AST\DirectiveNode $directive
25
    ): void {
26
        // nothing
27
    }
28
29
    public static function processModelTypeDirective(
30
        ModelGenerator $generator,
31
        \GraphQL\Language\AST\DirectiveNode $directive
32
    ): void {
33
        throw new Exception("Primary index is not implemented yet");
34
    }
35
36
    public static function processModelFieldDirective(
37
        ModelGenerator $generator,
38
        \GraphQL\Type\Definition\FieldDefinition $field,
39
        \GraphQL\Language\AST\DirectiveNode $directive
40
    ): void {
41
        // nothing
42
    }
43
44
    public static function processModelRelationshipDirective(
45
        ModelGenerator $generator,
46
        \GraphQL\Type\Definition\FieldDefinition $field,
47
        \GraphQL\Language\AST\DirectiveNode $directive
48
    ): string {
49
        // nothing
50
        return '';
51
    }
52
}
53