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