We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 2 |
| Paths | 1 |
| Total Lines | 74 |
| Code Lines | 60 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 59 |
| CRAP Score | 2 |
| Changes | 2 | ||
| Bugs | 0 | Features | 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 | 47 | ->isRequired() |
|
| 16 | 47 | ->requiresAtLeastOneElement(); |
|
|
|
|||
| 17 | |||
| 18 | 47 | $prototype = $node->useAttributeAsKey('name', false)->prototype('array'); |
|
| 19 | |||
| 20 | $prototype |
||
| 21 | 47 | ->beforeNormalization() |
|
| 22 | // Allow field type short syntax (Field: Type => Field: {type: Type}) |
||
| 23 | 47 | ->ifTrue(fn ($options) => \is_string($options)) |
|
| 24 | 47 | ->then(fn ($options) => ['type' => $options]) |
|
| 25 | 47 | ->end() |
|
| 26 | 47 | ->validate() |
|
| 27 | // Remove empty entries |
||
| 28 | ->always(function ($value) { |
||
| 29 | 37 | if (empty($value['validationGroups'])) { |
|
| 30 | 37 | unset($value['validationGroups']); |
|
| 31 | } |
||
| 32 | |||
| 33 | 37 | if (empty($value['args'])) { |
|
| 34 | 37 | unset($value['args']); |
|
| 35 | } |
||
| 36 | |||
| 37 | 37 | return $value; |
|
| 38 | 47 | }) |
|
| 39 | 47 | ->end() |
|
| 40 | 47 | ->children() |
|
| 41 | 47 | ->append($this->typeSection()) |
|
| 42 | 47 | ->append($this->validationSection(self::VALIDATION_LEVEL_CLASS)) |
|
| 43 | 47 | ->arrayNode('validationGroups') |
|
| 44 | 47 | ->beforeNormalization() |
|
| 45 | 47 | ->castToArray() |
|
| 46 | 47 | ->end() |
|
| 47 | 47 | ->prototype('scalar') |
|
| 48 | 47 | ->info('List of validation groups') |
|
| 49 | 47 | ->end() |
|
| 50 | 47 | ->end() |
|
| 51 | 47 | ->arrayNode('args') |
|
| 52 | 47 | ->info('Array of possible type arguments. Each entry is expected to be an array with following keys: name (string), type') |
|
| 53 | 47 | ->useAttributeAsKey('name', false) |
|
| 54 | 47 | ->prototype('array') |
|
| 55 | // Allow arg type short syntax (Arg: Type => Arg: {type: Type}) |
||
| 56 | 47 | ->beforeNormalization() |
|
| 57 | 47 | ->ifTrue(fn ($options) => \is_string($options)) |
|
| 58 | 47 | ->then(fn ($options) => ['type' => $options]) |
|
| 59 | 47 | ->end() |
|
| 60 | 47 | ->children() |
|
| 61 | 47 | ->append($this->typeSection(true)) |
|
| 62 | 47 | ->append($this->descriptionSection()) |
|
| 63 | 47 | ->append($this->defaultValueSection()) |
|
| 64 | 47 | ->append($this->validationSection(self::VALIDATION_LEVEL_PROPERTY)) |
|
| 65 | 47 | ->end() |
|
| 66 | 47 | ->end() |
|
| 67 | 47 | ->end() |
|
| 68 | 47 | ->variableNode('resolve') |
|
| 69 | 47 | ->info('Value resolver (expression language can be used here)') |
|
| 70 | 47 | ->end() |
|
| 71 | 47 | ->append($this->descriptionSection()) |
|
| 72 | 47 | ->append($this->deprecationReasonSection()) |
|
| 73 | 47 | ->variableNode('access') |
|
| 74 | 47 | ->info('Access control to field (expression language can be used here)') |
|
| 75 | 47 | ->end() |
|
| 76 | 47 | ->variableNode('public') |
|
| 77 | 47 | ->info('Visibility control to field (expression language can be used here)') |
|
| 78 | 47 | ->end() |
|
| 79 | 47 | ->variableNode('complexity') |
|
| 80 | 47 | ->info('Custom complexity calculator.') |
|
| 81 | 47 | ->end() |
|
| 82 | 47 | ->end(); |
|
| 83 | |||
| 84 | 47 | return $node; |
|
| 85 | } |
||
| 86 | |||
| 87 | 47 | protected function fieldsBuilderSection() |
|
| 88 | { |
||
| 89 | 47 | $node = self::createNode('builders'); |
|
| 102 |