Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Passed
Pull Request — master (#815)
by Timur
25:10
created

GraphQLServices::getAll()   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
declare(strict_types=1);
4
5
namespace Overblog\GraphQLBundle\Definition;
6
7
use GraphQL\Type\Definition\ResolveInfo;
8
use GraphQL\Type\Definition\Type;
9
use LogicException;
10
use Overblog\GraphQLBundle\Resolver\MutationResolver;
11
use Overblog\GraphQLBundle\Resolver\QueryResolver;
12
use Overblog\GraphQLBundle\Resolver\TypeResolver;
13
use Overblog\GraphQLBundle\Validator\InputValidator;
14
15
/**
16
 * Container for special services to be passed to all generated types.
17
 */
18
final class GraphQLServices
19
{
20
    private array $services;
21
    private TypeResolver $types;
22
    private QueryResolver $queryResolver;
23
    private MutationResolver $mutationResolver;
24
25
    public function __construct(
26
        TypeResolver $typeResolver,
27
        QueryResolver $queryResolver,
28
        MutationResolver $mutationResolver,
29
        array $services = []
30
    ) {
31
        $this->types = $typeResolver;
32
        $this->queryResolver = $queryResolver;
33
        $this->mutationResolver = $mutationResolver;
34
        $this->services = $services;
35
    }
36
37
    /**
38
     * @return mixed
39
     */
40
    public function get(string $name)
41
    {
42
        if (!isset($this->services[$name])) {
43
            throw new LogicException(sprintf('GraphQL service "%s" could not be located. You should define it.', $name));
44
        }
45
46
        return $this->services[$name];
47
    }
48
49
    /**
50
     * Get all GraphQL services.
51
     */
52
    public function getAll(): array
53
    {
54
        return $this->services;
55
    }
56
57
    public function has(string $name): bool
58
    {
59
        return isset($this->services[$name]);
60
    }
61
62
    /**
63
     * @param mixed ...$args
64
     *
65
     * @return mixed
66
     */
67
    public function query(string $alias, ...$args)
68
    {
69
        return $this->queryResolver->resolve([$alias, $args]);
70
    }
71
72
    /**
73
     * @param mixed ...$args
74
     *
75
     * @return mixed
76
     */
77
    public function mutation(string $alias, ...$args)
78
    {
79
        return $this->mutationResolver->resolve([$alias, $args]);
80
    }
81
82
    public function getType(string $typeName): ?Type
83
    {
84
        return $this->types->resolve($typeName);
85
    }
86
87
    /**
88
     * Creates an instance of InputValidator
89
     *
90
     * @param mixed $value
91
     * @param mixed $context
92
     */
93
    public function createInputValidator($value, ArgumentInterface $args, $context, ResolveInfo $info): InputValidator
94
    {
95
        return $this->services['input_validator_factory']->create(
96
            new ResolverArgs($value, $args, $context, $info)
97
        );
98
    }
99
}
100