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 ( b9b49e...4b752f )
by Jérémiah
48s
created

WrapArgumentConfigProcessor   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 37
Duplicated Lines 16.22 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
lcom 0
cbo 2
dl 6
loc 37
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B process() 3 23 5
A wrapFieldsArgument() 3 10 4

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
namespace Overblog\GraphQLBundle\Definition\ConfigProcessor;
4
5
use Overblog\GraphQLBundle\Definition\LazyConfig;
6
use Overblog\GraphQLBundle\Resolver\Resolver;
7
8
final class WrapArgumentConfigProcessor implements ConfigProcessorInterface
9
{
10
    public function process(LazyConfig $lazyConfig)
11
    {
12 78
        $lazyConfig->addPostLoader(function ($config) {
13 78 View Code Duplication
            if (isset($config['resolveField']) && is_callable($config['resolveField'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
14 10
                $config['resolveField'] = Resolver::wrapArgs($config['resolveField']);
15
            }
16
17 78
            if (isset($config['fields'])) {
18 73
                $config['fields'] = function () use ($config) {
19 73
                    $fields = $config['fields'];
20 73
                    if (is_callable($config['fields'])) {
21 73
                        $fields = $config['fields']();
22
                    }
23
24 73
                    return self::wrapFieldsArgument($fields);
25
                };
26
            }
27
28 78
            return $config;
29 78
        });
30
31 78
        return $lazyConfig;
32
    }
33
34 73
    private static function wrapFieldsArgument(array $fields)
35
    {
36 73
        foreach ($fields as &$field) {
37 73 View Code Duplication
            if (isset($field['resolve']) && is_callable($field['resolve'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
38 73
                $field['resolve'] = Resolver::wrapArgs($field['resolve']);
39
            }
40
        }
41
42 73
        return $fields;
43
    }
44
}
45