Code Duplication    Length = 53-53 lines in 2 locations

src/Type/Directives/IncludeDirective.php 1 location

@@ 12-64 (lines=53) @@
9
/**
10
 * Used to conditionally include fields.
11
 */
12
class IncludeDirective extends Directive
13
{
14
    /**
15
     * @var string
16
     */
17
    protected $name = 'include';
18
19
    /**
20
     * @var string
21
     */
22
    protected $description = 'Directs the executor to omit this field if the argument provided is false.';
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
    public function __construct()
43
    {
44
        $this->arguments = [
45
            new FieldArgument([
46
                'name' => 'if',
47
                'type' => new NonNullModifier(Type::booleanType()),
48
                'description' => 'Included if true.'
49
            ]),
50
        ];
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function getType()
57
    {
58
        if (!isset($this->type)) {
59
            $this->type = new NonNullModifier(Type::booleanType());
60
        }
61
62
        return $this->type;
63
    }
64
}
65

src/Type/Directives/SkipDirective.php 1 location

@@ 12-64 (lines=53) @@
9
/**
10
 * Used to conditionally exclude fields.
11
 */
12
class SkipDirective extends Directive
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
    public function __construct()
43
    {
44
        $this->arguments = [
45
            new FieldArgument([
46
                'name' => 'if',
47
                'type' => new NonNullModifier(Type::booleanType()),
48
                'description' => 'Skipped if true.'
49
            ]),
50
        ];
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function getType()
57
    {
58
        if (!isset($this->type)) {
59
            $this->type = new NonNullModifier(Type::booleanType());
60
        }
61
62
        return $this->type;
63
    }
64
}
65