Passed
Push — master ( cdd9bc...4528ae )
by Christoffer
02:20
created

IncludeDirective()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
use Digia\GraphQL\GraphQL;
4
use Digia\GraphQL\Type\Definition\Directive;
5
use Digia\GraphQL\Type\Definition\DirectiveInterface;
6
use function Digia\GraphQL\Util\arraySome;
7
8
/**
9
 * @return Directive
10
 */
11
function IncludeDirective(): Directive
12
{
13
    return GraphQL::make(GraphQL::INCLUDE_DIRECTIVE);
14
}
15
16
/**
17
 * @return Directive
18
 */
19
function SkipDirective(): Directive
20
{
21
    return GraphQL::make(GraphQL::SKIP_DIRECTIVE);
22
}
23
24
const DEFAULT_DEPRECATION_REASON = 'No longer supported';
25
26
/**
27
 * @return Directive
28
 */
29
function DeprecatedDirective(): Directive
30
{
31
    return GraphQL::make(GraphQL::DEPRECATED_DIRECTIVE);
32
}
33
34
/**
35
 * @return array
36
 */
37
function specifiedDirectives(): array
38
{
39
    return [
40
        IncludeDirective(),
41
        SkipDirective(),
42
        DeprecatedDirective(),
43
    ];
44
}
45
46
/**
47
 * @param DirectiveInterface $directive
48
 * @return bool
49
 */
50
function isSpecifiedDirective(DirectiveInterface $directive): bool
51
{
52
    return arraySome(
53
        specifiedDirectives(),
54
        function (DirectiveInterface $specifiedDirective) use ($directive) {
55
            return $specifiedDirective->getName() === $directive->getName();
56
        }
57
    );
58
}
59