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
Push — master ( 5c920d...e34953 )
by Jérémiah
05:53 queued 24s
created

ConfigExpressionProvider::getFunctions()   B

Complexity

Conditions 5
Paths 1

Size

Total Lines 133
Code Lines 76

Duplication

Lines 12
Ratio 9.02 %

Code Coverage

Tests 73
CRAP Score 5.1453

Importance

Changes 0
Metric Value
dl 12
loc 133
ccs 73
cts 89
cp 0.8202
rs 8.1463
c 0
b 0
f 0
cc 5
eloc 76
nc 1
nop 0
crap 5.1453

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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