| Conditions | 1 |
| Paths | 1 |
| Total Lines | 57 |
| Code Lines | 52 |
| 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 |
||
| 12 | public function getConfigTreeBuilder(): TreeBuilder |
||
| 13 | { |
||
| 14 | $treeBuilder = new TreeBuilder('gewebe_sylius_vat'); |
||
| 15 | |||
| 16 | $treeBuilder->getRootNode() |
||
| 17 | ->children() |
||
| 18 | ->arrayNode('order') |
||
| 19 | ->children() |
||
| 20 | ->booleanNode('recalculate')->defaultValue(true) |
||
| 21 | ->info('Order will be recalculated without taxes if possible.') |
||
| 22 | ->end() |
||
| 23 | ->end() |
||
| 24 | ->end() // order |
||
| 25 | ->arrayNode('required') |
||
| 26 | ->children() |
||
| 27 | ->booleanNode('default')->defaultValue(false) |
||
| 28 | ->info('VAT number is required by default.') |
||
| 29 | ->end() |
||
| 30 | ->booleanNode('company')->defaultValue(true) |
||
| 31 | ->info('VAT number is required for a company address.') |
||
| 32 | ->end() |
||
| 33 | ->arrayNode('countries') |
||
| 34 | ->scalarPrototype()->end() |
||
| 35 | ->info('VAT number is required for the specified countries.') |
||
| 36 | ->end() |
||
| 37 | ->end() |
||
| 38 | ->end() // required |
||
| 39 | ->arrayNode('validate') |
||
| 40 | ->children() |
||
| 41 | ->booleanNode('format')->defaultValue(true) |
||
| 42 | ->info('Verify the country-specific VAT number format.') |
||
| 43 | ->end() |
||
| 44 | ->booleanNode('country')->defaultValue(true) |
||
| 45 | ->info('Verify that the VAT number matches the selected country.') |
||
| 46 | ->end() |
||
| 47 | ->booleanNode('registration')->defaultValue(true) |
||
| 48 | ->info('Verify that the VAT number is successfully registered online.') |
||
| 49 | ->end() |
||
| 50 | ->booleanNode('on_service_unavailable')->defaultValue(false) |
||
| 51 | ->info('Validation will not fail if the VAT service is unavailable, ' |
||
| 52 | . 'but the VAT number is not verified, which can be tried again later.') |
||
| 53 | ->end() |
||
| 54 | ->end() |
||
| 55 | ->end() // validate |
||
| 56 | ->arrayNode('revalidate') |
||
| 57 | ->children() |
||
| 58 | ->booleanNode('on_login')->defaultValue(true) |
||
| 59 | ->info('VAT number will be revalidated again on login.') |
||
| 60 | ->end() |
||
| 61 | ->integerNode('expiration_days')->defaultValue(30) |
||
| 62 | ->info('Number of days after which the VAT number will be revalidated.') |
||
| 63 | ->end() |
||
| 64 | ->end() |
||
| 65 | ->end() // revalidate |
||
| 66 | ; |
||
| 67 | |||
| 68 | return $treeBuilder; |
||
| 69 | } |
||
| 71 |