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

Completed
Pull Request — master (#5)
by Jérémiah
07:11
created

TypeResolver::getType()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 27
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 6.0106

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 27
ccs 14
cts 15
cp 0.9333
rs 8.439
cc 6
eloc 14
nc 6
nop 1
crap 6.0106
1
<?php
2
3
/*
4
 * This file is part of the OverblogGraphQLBundle package.
5
 *
6
 * (c) Overblog <http://github.com/overblog/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Overblog\GraphQLBundle\Resolver;
13
14
use GraphQL\Type\Definition\Type;
15
16
class TypeResolver extends AbstractResolver
17
{
18
    /**
19
     * @param string $alias
20
     *
21
     * @return \GraphQL\Type\Definition\Type
22
     */
23 33
    public function resolve($alias)
24
    {
25 33
        if (null !== $type = $this->cache->fetch($alias)) {
26 25
            return $type;
27
        }
28
29 33
        $type = $this->getType($alias);
30
31 32
        $this->cache->save($alias, $type);
32
33 32
        return $type;
34
    }
35
36 33
    private function getType($alias)
37
    {
38 33
        if (!is_string($alias)) {
39 25
            return $alias;
40
        }
41
        // Non-Null
42 33
        if ('!' === $alias[strlen($alias) - 1]) {
43 13
            return Type::nonNull($this->getType(substr($alias, 0, -1)));
44
        }
45
        // List
46 33
        if ('[' === $alias[0]) {
47 7
            if (']' !== $alias[strlen($alias) - 1]) {
48
                throw new UnresolvableException(sprintf('Invalid type "%s"', $alias));
49
            }
50
51 7
            return Type::listOf($this->getType(substr($alias, 1, -1)));
52
        }
53
54 33
        $type = $this->getSolution($alias);
55 33
        if (null === $type) {
56 1
            throw new UnresolvableException(
57 1
                sprintf('Unknown type with alias "%s" (verified service tag)', $alias)
58 1
            );
59
        }
60
61 32
        return $type;
62
    }
63
64 33
    protected function supportedSolutionClass()
65
    {
66 33
        return Type::class;
67
    }
68
}
69