We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 6 |
Paths | 1 |
Total Lines | 141 |
Code Lines | 132 |
Lines | 0 |
Ratio | 0 % |
Tests | 130 |
CRAP Score | 6 |
Changes | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
37 | 13 | public function getConfigTreeBuilder() |
|
38 | { |
||
39 | 13 | $treeBuilder = new TreeBuilder(); |
|
40 | 13 | $rootNode = $treeBuilder->root('overblog_graphql'); |
|
41 | |||
42 | $rootNode |
||
43 | 13 | ->children() |
|
44 | 13 | ->arrayNode('definitions') |
|
45 | 13 | ->addDefaultsIfNotSet() |
|
46 | 13 | ->children() |
|
47 | 13 | ->scalarNode('internal_error_message')->defaultNull()->end() |
|
48 | 13 | ->booleanNode('show_debug_info')->defaultValue(false)->end() |
|
49 | 13 | ->booleanNode('config_validation')->defaultValue($this->debug)->end() |
|
50 | 13 | ->arrayNode('schema') |
|
51 | 13 | ->beforeNormalization() |
|
52 | ->ifTrue(function ($v) { |
||
53 | 10 | $needNormalization = isset($v['query']) && is_string($v['query']) || |
|
54 | isset($v['mutation']) && is_string($v['mutation']) || |
||
55 | 10 | isset($v['subscription']) && is_string($v['subscription']); |
|
56 | |||
57 | 10 | return $needNormalization; |
|
58 | 13 | }) |
|
59 | ->then(function ($v) { |
||
60 | 10 | return ['default' => $v]; |
|
61 | 13 | }) |
|
62 | 13 | ->end() |
|
63 | 13 | ->useAttributeAsKey('name') |
|
64 | 13 | ->prototype('array') |
|
65 | 13 | ->addDefaultsIfNotSet() |
|
66 | 13 | ->children() |
|
67 | 13 | ->scalarNode('query')->defaultNull()->end() |
|
68 | 13 | ->scalarNode('mutation')->defaultNull()->end() |
|
69 | 13 | ->scalarNode('subscription')->defaultNull()->end() |
|
70 | 13 | ->end() |
|
71 | 13 | ->end() |
|
72 | 13 | ->end() |
|
73 | 13 | ->arrayNode('mappings') |
|
74 | 13 | ->children() |
|
75 | 13 | ->arrayNode('types') |
|
76 | 13 | ->prototype('array') |
|
77 | 13 | ->addDefaultsIfNotSet() |
|
78 | 13 | ->children() |
|
79 | 13 | ->enumNode('type')->isRequired()->values(['yml', 'xml'])->end() |
|
80 | 13 | ->scalarNode('dir')->defaultNull()->end() |
|
81 | 13 | ->end() |
|
82 | 13 | ->end() |
|
83 | 13 | ->end() |
|
84 | 13 | ->end() |
|
85 | 13 | ->end() |
|
86 | 13 | ->arrayNode('exceptions') |
|
87 | 13 | ->addDefaultsIfNotSet() |
|
88 | 13 | ->children() |
|
89 | 13 | ->arrayNode('warnings') |
|
90 | 13 | ->treatNullLike([]) |
|
91 | 13 | ->prototype('scalar')->end() |
|
92 | 13 | ->end() |
|
93 | 13 | ->arrayNode('errors') |
|
94 | 13 | ->treatNullLike([]) |
|
95 | 13 | ->prototype('scalar')->end() |
|
96 | 13 | ->end() |
|
97 | 13 | ->arrayNode('types') |
|
98 | 13 | ->addDefaultsIfNotSet() |
|
99 | 13 | ->children() |
|
100 | 13 | ->scalarNode('warnings') |
|
101 | 13 | ->defaultValue(ErrorHandler::DEFAULT_USER_WARNING_CLASS) |
|
102 | 13 | ->end() |
|
103 | 13 | ->scalarNode('errors') |
|
104 | 13 | ->defaultValue(ErrorHandler::DEFAULT_USER_ERROR_CLASS) |
|
105 | 13 | ->end() |
|
106 | 13 | ->end() |
|
107 | 13 | ->end() |
|
108 | 13 | ->end() |
|
109 | 13 | ->end() |
|
110 | |||
111 | 13 | ->arrayNode('builders') |
|
112 | 13 | ->children() |
|
113 | 13 | ->arrayNode('field') |
|
114 | 13 | ->prototype('array') |
|
115 | 13 | ->children() |
|
116 | 13 | ->scalarNode('alias')->isRequired()->end() |
|
117 | 13 | ->scalarNode('class')->isRequired()->end() |
|
118 | 13 | ->end() |
|
119 | 13 | ->end() |
|
120 | 13 | ->end() |
|
121 | 13 | ->arrayNode('args') |
|
122 | 13 | ->prototype('array') |
|
123 | 13 | ->children() |
|
124 | 13 | ->scalarNode('alias')->isRequired()->end() |
|
125 | 13 | ->scalarNode('class')->isRequired()->end() |
|
126 | 13 | ->end() |
|
127 | 13 | ->end() |
|
128 | 13 | ->end() |
|
129 | 13 | ->end() |
|
130 | 13 | ->end() |
|
131 | |||
132 | 13 | ->end() |
|
133 | 13 | ->end() |
|
134 | 13 | ->arrayNode('templates') |
|
135 | 13 | ->addDefaultsIfNotSet() |
|
136 | 13 | ->children() |
|
137 | 13 | ->scalarNode('graphiql') |
|
138 | 13 | ->defaultValue('OverblogGraphQLBundle:GraphiQL:index.html.twig') |
|
139 | 13 | ->end() |
|
140 | 13 | ->end() |
|
141 | 13 | ->end() |
|
142 | 13 | ->arrayNode('services') |
|
143 | 13 | ->addDefaultsIfNotSet() |
|
144 | 13 | ->children() |
|
145 | 13 | ->scalarNode('executor') |
|
146 | 13 | ->defaultValue('overblog_graphql.executor.default') |
|
147 | 13 | ->end() |
|
148 | 13 | ->scalarNode('promise_adapter') |
|
149 | 13 | ->defaultValue('overblog_graphql.promise_adapter.default') |
|
150 | 13 | ->end() |
|
151 | 13 | ->scalarNode('expression_language') |
|
152 | 13 | ->defaultValue('overblog_graphql.expression_language.default') |
|
153 | 13 | ->end() |
|
154 | 13 | ->scalarNode('cache_expression_language_parser') |
|
155 | 13 | ->defaultValue('overblog_graphql.cache_expression_language_parser.default') |
|
156 | 13 | ->end() |
|
157 | 13 | ->end() |
|
158 | 13 | ->end() |
|
159 | 13 | ->arrayNode('security') |
|
160 | 13 | ->addDefaultsIfNotSet() |
|
161 | 13 | ->children() |
|
162 | 13 | ->append($this->addSecurityQuerySection('query_max_depth', QueryDepth::DISABLED)) |
|
163 | 13 | ->append($this->addSecurityQuerySection('query_max_complexity', QueryComplexity::DISABLED)) |
|
164 | 13 | ->end() |
|
165 | 13 | ->end() |
|
166 | 13 | ->arrayNode('versions') |
|
167 | 13 | ->addDefaultsIfNotSet() |
|
168 | 13 | ->children() |
|
169 | 13 | ->scalarNode('graphiql')->defaultValue('0.7.8')->end() |
|
170 | 13 | ->scalarNode('react')->defaultValue('15.3.2')->end() |
|
171 | 13 | ->scalarNode('fetch')->defaultValue('2.0.1')->end() |
|
172 | 13 | ->end() |
|
173 | 13 | ->end() |
|
174 | 13 | ->end(); |
|
175 | |||
176 | 13 | return $treeBuilder; |
|
177 | } |
||
178 | |||
206 |