We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 1 |
Paths | 1 |
Total Lines | 52 |
Code Lines | 43 |
Lines | 0 |
Ratio | 0 % |
Tests | 43 |
CRAP Score | 1 |
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 |
||
15 | 29 | protected function outputFieldsSelection($name) |
|
16 | { |
||
17 | 29 | $builder = new TreeBuilder(); |
|
18 | 29 | $node = $builder->root($name); |
|
19 | $node |
||
20 | 29 | ->isRequired() |
|
21 | 29 | ->requiresAtLeastOneElement(); |
|
22 | |||
23 | /* @var ArrayNodeDefinition $prototype */ |
||
24 | 29 | $prototype = $node->useAttributeAsKey('name', false)->prototype('array'); |
|
25 | |||
26 | $prototype |
||
27 | 29 | ->children() |
|
28 | 29 | ->append($this->typeSelection()) |
|
29 | 29 | ->arrayNode('args') |
|
30 | 29 | ->info('Array of possible type arguments. Each entry is expected to be an array with following keys: name (string), type') |
|
31 | 29 | ->useAttributeAsKey('name', false) |
|
32 | 29 | ->prototype('array') |
|
33 | // Allow arg type short syntax (Arg: Type => Arg: {type: Type}) |
||
34 | 29 | ->beforeNormalization() |
|
35 | 29 | ->ifTrue(function ($options) { |
|
36 | 17 | return is_string($options); |
|
37 | 29 | }) |
|
38 | 29 | ->then(function ($options) { |
|
39 | 1 | return ['type' => $options]; |
|
40 | 29 | }) |
|
41 | 29 | ->end() |
|
42 | 29 | ->children() |
|
43 | 29 | ->append($this->typeSelection(true)) |
|
44 | 29 | ->append($this->descriptionSection()) |
|
45 | 29 | ->append($this->defaultValueSection()) |
|
46 | 29 | ->end() |
|
47 | 29 | ->end() |
|
48 | 29 | ->end() |
|
49 | 29 | ->variableNode('resolve') |
|
50 | 29 | ->info('Value resolver (expression language can be use here)') |
|
51 | 29 | ->end() |
|
52 | 29 | ->append($this->descriptionSection()) |
|
53 | 29 | ->append($this->deprecationReasonSelection()) |
|
54 | 29 | ->variableNode('access') |
|
55 | 29 | ->info('Access control to field (expression language can be use here)') |
|
56 | 29 | ->end() |
|
57 | 29 | ->variableNode('public') |
|
58 | 29 | ->info('Visibility control to field (expression language can be use here)') |
|
59 | 29 | ->end() |
|
60 | 29 | ->variableNode('complexity') |
|
61 | 29 | ->info('Custom complexity calculator.') |
|
62 | 29 | ->end() |
|
63 | 29 | ->end(); |
|
64 | |||
65 | 29 | return $node; |
|
66 | } |
||
67 | } |
||
68 |