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
Push — master ( cc83a8...7c2c4f )
by Jérémiah
48s
created

GlobalResolver   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

Changes 0
Metric Value
wmc 8
lcom 2
cbo 2
dl 0
loc 78
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A idFetcher() 0 12 3
A typeResolver() 0 10 3
A resolveAllObjects() 0 8 1
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 Overblog\GraphQLBundle\Relay\Node\GlobalId;
15
use Overblog\GraphQLBundle\Resolver\TypeResolver;
16
17
class GlobalResolver
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
        1 => [
35
            'photoId' => 1,
36
            'width' => 300,
37
        ],
38
        2 => [
39
            'photoId' => 2,
40
            'width' => 400,
41
        ],
42
    ];
43
44
    private $postData = [
45
        1 => [
46
            'id' => 1,
47
            'text' => 'lorem',
48
            'status' => 2,
49
        ],
50
        2 => [
51
            'id' => 2,
52
            'text' => 'ipsum',
53
            'status' => 1,
54
        ],
55
    ];
56
57
    public function __construct(TypeResolver $typeResolver)
58
    {
59
        $this->typeResolver = $typeResolver;
60
    }
61
62
    public function idFetcher($globalId)
63
    {
64
        list($type, $id) = array_values(GlobalId::fromGlobalId($globalId));
65
66
        if ($type === 'User') {
67
            return $this->userData[$id];
68
        } elseif ($type === 'Photo') {
69
            return $this->photoData[$id];
70
        } else {
71
            return $this->postData[$id];
72
        }
73
    }
74
75
    public function typeResolver($value)
76
    {
77
        if (isset($value['name'])) {
78
            return $this->typeResolver->resolve('User');
79
        } elseif (isset($value['photoId'])) {
80
            return $this->typeResolver->resolve('Photo');
81
        } else {
82
            return $this->typeResolver->resolve('Post');
83
        }
84
    }
85
86
    public function resolveAllObjects()
87
    {
88
        return [
89
            $this->userData[1], $this->userData[2],
90
            $this->photoData[1], $this->photoData[2],
91
            $this->postData[1], $this->postData[2],
92
        ];
93
    }
94
}
95