| Conditions | 1 |
| Paths | 1 |
| Total Lines | 54 |
| Lines | 0 |
| Ratio | 0 % |
| 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 |
||
| 25 | public function getConfigTreeBuilder(): TreeBuilder |
||
| 26 | { |
||
| 27 | $treeBuilder = new TreeBuilder('sylius_shop'); |
||
| 28 | /** @var ArrayNodeDefinition $rootNode */ |
||
| 29 | $rootNode = $treeBuilder->getRootNode(); |
||
| 30 | |||
| 31 | $rootNode |
||
| 32 | ->children() |
||
| 33 | ->enumNode('locale_switcher')->values(['storage', 'url'])->defaultValue('url')->end() |
||
| 34 | ->scalarNode('firewall_context_name')->defaultValue('shop')->end() |
||
| 35 | ->arrayNode('checkout_resolver') |
||
| 36 | ->addDefaultsIfNotSet() |
||
| 37 | ->children() |
||
| 38 | ->booleanNode('enabled') |
||
| 39 | ->defaultTrue() |
||
| 40 | ->end() |
||
| 41 | ->scalarNode('pattern') |
||
| 42 | ->defaultValue('/checkout/.+') |
||
| 43 | ->validate() |
||
| 44 | ->ifTrue( |
||
| 45 | /** @param mixed $pattern */ |
||
| 46 | function ($pattern) { |
||
| 47 | return !is_string($pattern); |
||
| 48 | } |
||
| 49 | ) |
||
| 50 | ->thenInvalid('Invalid pattern "%s"') |
||
| 51 | ->end() |
||
| 52 | ->end() |
||
| 53 | ->arrayNode('route_map') |
||
| 54 | ->useAttributeAsKey('name') |
||
| 55 | ->arrayPrototype() |
||
| 56 | ->children() |
||
| 57 | ->scalarNode('route') |
||
| 58 | ->cannotBeEmpty() |
||
| 59 | ->isRequired() |
||
| 60 | ->end() |
||
| 61 | ->end() |
||
| 62 | ->end() |
||
| 63 | ->end() |
||
| 64 | ->end() |
||
| 65 | ->end() |
||
| 66 | ->arrayNode('product_grid') |
||
| 67 | ->addDefaultsIfNotSet() |
||
| 68 | ->children() |
||
| 69 | ->booleanNode('include_all_descendants') |
||
| 70 | ->defaultFalse() |
||
| 71 | ->end() |
||
| 72 | ->end() |
||
| 73 | ->end() |
||
| 74 | ->end() |
||
| 75 | ; |
||
| 76 | |||
| 77 | return $treeBuilder; |
||
| 78 | } |
||
| 79 | } |
||
| 80 |