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

Boolean()   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\ScalarType;
7
use Digia\GraphQL\Type\Definition\TypeInterface;
8
use function Digia\GraphQL\Util\arraySome;
9
10
/**
11
 * @return ScalarType
12
 */
13
function Boolean(): ScalarType
14
{
15
    return GraphQL::make('GraphQLBoolean');
16
}
17
18
/**
19
 * @return ScalarType
20
 */
21
function Float(): ScalarType
22
{
23
    return GraphQL::make('GraphQLFloat');
24
}
25
26
/**
27
 * @return ScalarType
28
 */
29
function Int(): ScalarType
30
{
31
    return GraphQL::make('GraphQLInt');
32
}
33
34
/**
35
 * @return ScalarType
36
 */
37
function ID(): ScalarType
38
{
39
    return GraphQL::make('GraphQLID');
40
}
41
42
/**
43
 * @return ScalarType
44
 */
45
function String(): ScalarType
46
{
47
    return GraphQL::make('GraphQLString');
48
}
49
50
/**
51
 * @return array
52
 */
53
function specifiedScalarTypes(): array
54
{
55
    return [
56
        String(),
57
        Int(),
58
        Float(),
59
        Boolean(),
60
        ID(),
61
    ];
62
}
63
64
/**
65
 * @param TypeInterface $type
66
 * @return bool
67
 */
68
function isSpecifiedScalarType(TypeInterface $type): bool
69
{
70
    return arraySome(
71
        specifiedScalarTypes(),
72
        function (ScalarType $specifiedScalarType) use ($type) {
73
            /** @noinspection PhpUndefinedMethodInspection */
74
            return $type->getName() === $specifiedScalarType->getName();
0 ignored issues
show
Bug introduced by
The method getName() does not exist on Digia\GraphQL\Type\Definition\TypeInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Digia\GraphQL\Type\Defin...n\AbstractTypeInterface or Digia\GraphQL\Type\Defin...n\WrappingTypeInterface. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

74
            return $type->/** @scrutinizer ignore-call */ getName() === $specifiedScalarType->getName();
Loading history...
75
        }
76
    );
77
}
78