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
23:14
created

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