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 (#40)
by Jérémiah
13:22
created

ConfigExpressionProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 124
Duplicated Lines 9.68 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 96.05%

Importance

Changes 6
Bugs 2 Features 2
Metric Value
wmc 5
c 6
b 2
f 2
lcom 0
cbo 1
dl 12
loc 124
ccs 73
cts 76
cp 0.9605
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B getFunctions() 12 121 5

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\ExpressionLanguage;
13
14
use Overblog\GraphQLBundle\Generator\TypeGenerator;
15
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
16
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
17
18
class ConfigExpressionProvider implements ExpressionFunctionProviderInterface
19
{
20 24
    public function getFunctions()
21
    {
22
        return [
23 24
            new ExpressionFunction(
24 24
                'service',
25
                function ($value) {
26 3
                    return sprintf('$container->get(%s)', $value);
27 24
                },
28
                function () {}
29 24
            ),
30
31 24
            new ExpressionFunction(
32 24
                'parameter',
33
                function ($value) {
34 1
                    return sprintf('$container->getParameter(%s)', $value);
35 24
                },
36
                function () {}
37 24
            ),
38
39 24
            new ExpressionFunction(
40 24
                'isTypeOf',
41
                function ($className) {
42 1
                    return sprintf('($className = %s) && $value instanceof $className', $className);
43 24
                },
44
                function () {}
45 24
            ),
46
47 24
            new ExpressionFunction(
48 24
                'resolver',
49
                function ($alias, $args = '[]') {
50 7
                    return sprintf('$container->get(\'overblog_graphql.resolver_resolver\')->resolve([%s, %s])', $alias, $args);
51 24
                },
52
                function () {}
53 24
            ),
54
55 24
            new ExpressionFunction(
56 24
                'mutateAndGetPayloadCallback',
57 View Code Duplication
                function ($mutateAndGetPayload) {
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...
58
                    $code = 'function ($value) use ('.TypeGenerator::USE_FOR_CLOSURES.', $args, $info) { ';
59
                    $code .= 'return '.$mutateAndGetPayload.'; }';
60
61
                    return $code;
62 24
                },
63
                function () {}
64 24
            ),
65
66 24
            new ExpressionFunction(
67 24
                'mutateAndGetPayloadCallback',
68 View Code Duplication
                function ($mutateAndGetPayload) {
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...
69 2
                    $code = 'function ($value) use ('.TypeGenerator::USE_FOR_CLOSURES.', $args, $info) { ';
70 2
                    $code .= 'return '.$mutateAndGetPayload.'; }';
71
72 2
                    return $code;
73 24
                },
74
                function () {}
75 24
            ),
76
77 24
            new ExpressionFunction(
78 24
                'idFetcherCallback',
79
                function ($idFetcher) {
80 2
                    $code = 'function ($value) use ('.TypeGenerator::USE_FOR_CLOSURES.', $args, $info) { ';
81 2
                    $code .= 'return '.$idFetcher.'; }';
82
83 2
                    return $code;
84 24
                },
85
                function () {}
86 24
            ),
87
88 24
            new ExpressionFunction(
89 24
                'resolveSingleInputCallback',
90
                function ($resolveSingleInput) {
91 1
                    $code = 'function ($value) use ('.TypeGenerator::USE_FOR_CLOSURES.', $args, $info) { ';
92 1
                    $code .= 'return '.$resolveSingleInput.'; }';
93
94 1
                    return $code;
95 24
                },
96
                function () {}
97 24
            ),
98
99 24
            new ExpressionFunction(
100 24
                'mutation',
101
                function ($alias, $args = '[]') {
102 2
                    return sprintf('$container->get(\'overblog_graphql.mutation_resolver\')->resolve([%s, %s])', $alias, $args);
103 24
                },
104
                function () {}
105 24
            ),
106
107 24
            new ExpressionFunction(
108 24
                'globalId',
109
                function ($id, $typeName = null) {
110 1
                    $typeNameEmpty = null === $typeName || '""' === $typeName || 'null' === $typeName || 'false' === $typeName;
111
112 1
                    return sprintf(
113 1
                        '\\Overblog\\GraphQLBundle\\Relay\\Node\\GlobalId::toGlobalId(%s, %s)',
114 1
                        sprintf($typeNameEmpty ? '$info->parentType->name' : '%s', $typeName),
115
                        $id
116 1
                    );
117 24
                },
118
                function () {}
119 24
            ),
120
121 24
            new ExpressionFunction(
122 24
                'fromGlobalId',
123
                function ($globalId) {
124 1
                    return sprintf(
125 1
                        '\\Overblog\\GraphQLBundle\\Relay\\Node\\GlobalId::fromGlobalId(%s)',
126
                        $globalId
127 1
                    );
128 24
                },
129
                function () {}
130 24
            ),
131
132 24
            new ExpressionFunction(
133 24
                'newObject',
134
                function ($className, $args = '[]') {
135 1
                    return sprintf('(new \ReflectionClass(%s))->newInstanceArgs(%s)', $className, $args);
136 24
                },
137
                function () {}
138 24
            ),
139 24
        ];
140
    }
141
}
142