Passed
Pull Request — master (#21)
by Christoffer
02:13
created

GraphQLFloat()   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
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Digia\GraphQL\Type;
4
5
use Digia\GraphQL\GraphQLRuntime;
6
use Digia\GraphQL\Type\Definition\ScalarType;
7
use Digia\GraphQL\Type\Definition\TypeInterface;
8
use function Digia\GraphQL\Util\arraySome;
9
10
const MAX_INT = 2147483647;
11
const MIN_INT = -2147483648;
12
13
/**
14
 * @return ScalarType
15
 */
16
function GraphQLBoolean(): ScalarType
17
{
18
    return GraphQLRuntime::get('GraphQLBoolean');
19
}
20
21
/**
22
 * @return ScalarType
23
 */
24
function GraphQLFloat(): ScalarType
25
{
26
    return GraphQLRuntime::get('GraphQLFloat');
27
}
28
29
/**
30
 * @return ScalarType
31
 */
32
function GraphQLInt(): ScalarType
33
{
34
    return GraphQLRuntime::get('GraphQLInt');
35
}
36
37
/**
38
 * @return ScalarType
39
 */
40
function GraphQLID(): ScalarType
41
{
42
    return GraphQLRuntime::get('GraphQLID');
43
}
44
45
/**
46
 * @return ScalarType
47
 */
48
function GraphQLString(): ScalarType
49
{
50
    return GraphQLRuntime::get('GraphQLString');
51
}
52
53
/**
54
 * @return array
55
 */
56
function specifiedScalarTypes(): array
57
{
58
    return [
59
        GraphQLString(),
60
        GraphQLInt(),
61
        GraphQLFloat(),
62
        GraphQLBoolean(),
63
        GraphQLID(),
64
    ];
65
}
66
67
/**
68
 * @param TypeInterface $type
69
 * @return bool
70
 */
71
function isSpecifiedScalarType(TypeInterface $type): bool
72
{
73
    return arraySome(
74
        specifiedScalarTypes(),
75
        function (ScalarType $specifiedScalarType) use ($type) {
76
            return $type->getName() === $specifiedScalarType->getName();
77
        }
78
    );
79
}
80