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

ConfigExpressionProvider::getFunctions()   B

Complexity

Conditions 5
Paths 1

Size

Total Lines 99
Code Lines 58

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 59
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 99
ccs 59
cts 59
cp 1
rs 8.1585
c 0
b 0
f 0
cc 5
eloc 58
nc 1
nop 0
crap 5

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