SkipDirective::getType()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 3.1852

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 8
loc 8
ccs 2
cts 6
cp 0.3333
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
crap 3.1852
1
<?php
2
3
namespace Fubhy\GraphQL\Type\Directives;
4
5
use Fubhy\GraphQL\Type\Definition\FieldArgument;
6
use Fubhy\GraphQL\Type\Definition\Types\NonNullModifier;
7
use Fubhy\GraphQL\Type\Definition\Types\Type;
8
9
/**
10
 * Used to conditionally exclude fields.
11
 */
12 View Code Duplication
class SkipDirective extends Directive
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
{
14
    /**
15
     * @var string
16
     */
17
    protected $name = 'skip';
18
19
    /**
20
     * @var string
21
     */
22
    protected $description = 'Directs the executor to omit this field if the argument provided is true.';
23
24
    /**
25
     * @var bool
26
     */
27
    protected $onOperation = FALSE;
28
29
    /**
30
     * @var bool
31
     */
32
    protected $onFragment = TRUE;
33
34
    /**
35
     * @var bool
36
     */
37
    protected $onField = TRUE;
38
39
    /**
40
     * Constructor.
41
     */
42 3
    public function __construct()
43
    {
44 3
        $this->arguments = [
45 3
            new FieldArgument([
46 3
                'name' => 'if',
47 3
                'type' => new NonNullModifier(Type::booleanType()),
48
                'description' => 'Skipped if true.'
49 3
            ]),
50
        ];
51 3
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56 3
    public function getType()
57 3
    {
58
        if (!isset($this->type)) {
59
            $this->type = new NonNullModifier(Type::booleanType());
60
        }
61
62
        return $this->type;
63
    }
64
}
65