Passed
Pull Request — master (#270)
by Christoffer
02:09
created

Int()   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
namespace Digia\GraphQL\Type;
4
5
use Digia\GraphQL\GraphQL;
6
use Digia\GraphQL\Type\Definition\NamedTypeInterface;
7
use Digia\GraphQL\Type\Definition\ScalarType;
8
use function Digia\GraphQL\Util\arraySome;
9
10
/**
11
 * @return ScalarType
12
 */
13
function BooleanType(): ScalarType
14
{
15
    return GraphQL::make('GraphQLBoolean');
16
}
17
18
/**
19
 * @return ScalarType
20
 */
21
function FloatType(): ScalarType
22
{
23
    return GraphQL::make('GraphQLFloat');
24
}
25
26
/**
27
 * @return ScalarType
28
 */
29
function IntType(): ScalarType
30
{
31
    return GraphQL::make('GraphQLInt');
32
}
33
34
/**
35
 * @return ScalarType
36
 */
37
function IDType(): ScalarType
38
{
39
    return GraphQL::make('GraphQLID');
40
}
41
42
/**
43
 * @return ScalarType
44
 */
45
function StringType(): ScalarType
46
{
47
    return GraphQL::make('GraphQLString');
48
}
49
50
/**
51
 * @return array
52
 */
53
function specifiedScalarTypes(): array
54
{
55
    return [
56
        StringType(),
57
        IntType(),
58
        FloatType(),
59
        BooleanType(),
60
        IDType(),
61
    ];
62
}
63
64
/**
65
 * @param NamedTypeInterface $type
66
 * @return bool
67
 */
68
function isSpecifiedScalarType(NamedTypeInterface $type): bool
69
{
70
    return arraySome(
71
        specifiedScalarTypes(),
72
        function (ScalarType $specifiedScalarType) use ($type) {
73
            return $type->getName() === $specifiedScalarType->getName();
74
        }
75
    );
76
}
77