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 (#4)
by Jérémiah
06:39
created

FieldResolver::resolve()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 10
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 2.0185
Metric Value
dl 10
loc 10
ccs 5
cts 6
cp 0.8333
rs 9.4285
cc 2
eloc 6
nc 2
nop 1
crap 2.0185
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 View Code Duplication
class FieldResolver extends AbstractResolver
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
15
{
16
    /**
17
     * @param $alias
18
     *
19
     * @return mixed
20
     */
21 2
    public function resolve($alias)
22
    {
23 2
        if (null !== $field = $this->cache->fetch($alias)) {
24
            return $field;
25
        }
26 2
        $field = $this->getFieldFromAlias($alias);
27 1
        $this->cache->save($alias, $field);
28
29 1
        return $field;
30
    }
31
32 2
    private function getFieldServiceIdFromAlias($alias)
33
    {
34 2
        $typesMapping = $this->container->getParameter('overblog_graphql.fields_mapping');
35
36 2
        if (!isset($typesMapping[$alias]['id'])) {
37 1
            throw new UnresolvableException(sprintf('Unknown field with alias "%s" (verified service tag)', $alias));
38
        }
39
40 1
        return $typesMapping[$alias]['id'];
41
    }
42
43 2
    private function getFieldFromAlias($alias)
44
    {
45 2
        $serviceId = $this->getFieldServiceIdFromAlias($alias);
46
47 1
        return $serviceId !== null ? $this->container->get($serviceId) : null;
48
    }
49
}
50