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
Push — master ( 180290...4c80a4 )
by Jérémiah
01:37
created

NodeResolver::resolvePhotoField()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 3
nop 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
17
class NodeResolver
18
{
19
    /** @var TypeResolver */
20
    private $typeResolver;
21
22
    private $userData = [
23
        '1' => [
24
            'id' => 1,
25
            'name' => 'John Doe',
26
        ],
27
        '2' => [
28
            'id' => 2,
29
            'name' => 'Jane Smith',
30
        ],
31
    ];
32
33
    private $photoData = [
34
        '3' => [
35
            'photoID' => 3,
36
            'photoWidth' => 300,
37
        ],
38
        '4' => [
39
            'photoID' => 4,
40
            'photoWidth' => 400,
41
        ],
42
    ];
43
44
    public function __construct(TypeResolver $typeResolver)
45
    {
46
        $this->typeResolver = $typeResolver;
47
    }
48
49
    public function resolvePhotoField($value, ResolveInfo $info)
50
    {
51
        switch ($info->fieldName) {
52
            case 'id':
53
                return $value['photoID'];
54
            case 'width':
55
                return $value['photoWidth'];
56
            default:
57
                return null;
58
        }
59
    }
60
61
    public function idFetcher($id)
62
    {
63
        if (isset($this->userData[$id])) {
64
            return $this->userData[$id];
65
        } elseif (isset($this->photoData[$id])) {
66
            return $this->photoData[$id];
67
        }
68
69
        return;
70
    }
71
72
    public function typeResolver($value)
73
    {
74
        if (isset($value['name'])) {
75
            return $this->typeResolver->resolve('User');
76
        } else {
77
            return $this->typeResolver->resolve('Photo');
78
        }
79
    }
80
}
81