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   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 92.86%

Importance

Changes 1
Bugs 1 Features 1
Metric Value
wmc 6
c 1
b 1
f 1
lcom 1
cbo 4
dl 36
loc 36
ccs 13
cts 14
cp 0.9286
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getFieldServiceIdFromAlias() 10 10 2
A getFieldFromAlias() 6 6 2
A resolve() 10 10 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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