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 (#137)
by Jérémiah
05:56
created

NodeResolver   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Importance

Changes 0
Metric Value
wmc 9
lcom 2
cbo 3
dl 0
loc 66
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A resolvePhotoField() 0 11 3
A idFetcher() 0 10 3
A typeResolver() 0 8 2
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\Tests\Functional\App\Resolver;
13
14
use GraphQL\Type\Definition\ResolveInfo;
15
use Overblog\GraphQLBundle\Resolver\TypeResolver;
16
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
17
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
18
19
class NodeResolver implements ContainerAwareInterface
20
{
21
    use ContainerAwareTrait;
22
23
    /** @var TypeResolver */
24
    private $typeResolver;
25
26
    private $userData = [
27
        '1' => [
28
            'id' => 1,
29
            'name' => 'John Doe',
30
        ],
31
        '2' => [
32
            'id' => 2,
33
            'name' => 'Jane Smith',
34
        ],
35
    ];
36
37
    private $photoData = [
38
        '3' => [
39
            'photoID' => 3,
40
            'photoWidth' => 300,
41
        ],
42
        '4' => [
43
            'photoID' => 4,
44
            'photoWidth' => 400,
45
        ],
46
    ];
47
48
    public function __construct(TypeResolver $typeResolver)
49
    {
50
        $this->typeResolver = $typeResolver;
51
    }
52
53
    public function resolvePhotoField($value, ResolveInfo $info)
54
    {
55
        switch ($info->fieldName) {
56
            case 'id':
57
                return $value['photoID'];
58
            case 'width':
59
                return $value['photoWidth'];
60
            default:
61
                return null;
62
        }
63
    }
64
65
    public function idFetcher($id)
66
    {
67
        if (isset($this->userData[$id])) {
68
            return $this->userData[$id];
69
        } elseif (isset($this->photoData[$id])) {
70
            return $this->photoData[$id];
71
        }
72
73
        return;
74
    }
75
76
    public function typeResolver($value)
77
    {
78
        if (isset($value['name'])) {
79
            return $this->typeResolver->resolve('User');
80
        } else {
81
            return $this->typeResolver->resolve('Photo');
82
        }
83
    }
84
}
85