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

AbstractResolver::supportsSolution()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
crap 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\Resolver;
13
14
use Overblog\GraphQLBundle\Resolver\Cache\CacheInterface;
15
use Overblog\GraphQLBundle\Resolver\Cache\ArrayCache;
16
17
abstract class AbstractResolver implements ResolverInterface
18
{
19
    /**
20
     * @var array
21
     */
22
    private $solutions = [];
23
24
    /**
25
     * @var array
26
     */
27
    private $solutionOptions = [];
28
29
    /**
30
     * @var CacheInterface
31
     */
32
    protected $cache;
33
34 41
    public function __construct(CacheInterface $cache = null)
35
    {
36 41
        $this->cache = null !== $cache ? $cache : new ArrayCache();
37 41
    }
38
39 41
    public function addSolution($name, $solution, $options = [])
40
    {
41 41
        if (!$this->supportsSolution($solution)) {
42
            throw new UnsupportedResolverException(
43
                sprintf('Resolver "%s" must be "%s" "%s" given.', $name, $this->supportedSolutionClass(), get_class($solution))
44
            );
45
        }
46
47 41
        $this->solutions[$name] = $solution;
48 41
        $this->solutionOptions[$name] = $options;
49
50 41
        return $this;
51
    }
52
53
    /**
54
     * @return array
55
     */
56
    public function getSolutions()
57
    {
58
        return $this->solutions;
59
    }
60
61
    /**
62
     * @param $name
63
     *
64
     * @return mixed
65
     */
66 41
    public function getSolution($name)
67
    {
68 41
        return isset($this->solutions[$name]) ? $this->solutions[$name] : null;
69
    }
70
71
    /**
72
     * @param $name
73
     *
74
     * @return mixed
75
     */
76 17
    public function getSolutionOptions($name)
77
    {
78 17
        return isset($this->solutionOptions[$name]) ? $this->solutionOptions[$name] : [];
79
    }
80
81
    /**
82
     * @param $input
83
     *
84
     * @return mixed
85
     */
86
    abstract public function resolve($input);
87
88
    /**
89
     * @param mixed $solution
90
     *
91
     * @return bool
92
     */
93 41
    protected function supportsSolution($solution)
94
    {
95 41
        $supportedClass = $this->supportedSolutionClass();
96
97 41
        return  null === $supportedClass || $solution instanceof $supportedClass;
98
    }
99
100
    /**
101
     * default return null to accept mixed type.
102
     *
103
     * @return null|string supported class name
104
     */
105 33
    protected function supportedSolutionClass()
106
    {
107 33
        return;
108
    }
109
}
110