| Conditions | 2 |
| Paths | 2 |
| Total Lines | 59 |
| 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 |
||
| 10 | public function getConfigTreeBuilder(): TreeBuilder |
||
| 11 | { |
||
| 12 | if (method_exists(TreeBuilder::class, 'getRootNode')) { |
||
| 13 | // Symfony 4 |
||
| 14 | $treeBuilder = new TreeBuilder('my_builder_cronos'); |
||
| 15 | $rootNode = $treeBuilder->getRootNode(); |
||
| 16 | } else { |
||
| 17 | // Symfony 3 |
||
| 18 | $treeBuilder = new TreeBuilder(); |
||
|
|
|||
| 19 | $rootNode = $treeBuilder->root('my_builder_cronos'); |
||
| 20 | } |
||
| 21 | |||
| 22 | $rootNode |
||
| 23 | ->children() |
||
| 24 | ->arrayNode('exporter') |
||
| 25 | ->addDefaultsIfNotSet() |
||
| 26 | ->children() |
||
| 27 | ->scalarNode('key') |
||
| 28 | ->isRequired() |
||
| 29 | ->cannotBeEmpty() |
||
| 30 | ->info('Unique key that wraps all the cron configured for the current application.') |
||
| 31 | ->example('my_symfony_app') |
||
| 32 | ->end() |
||
| 33 | ->scalarNode('mailto') |
||
| 34 | ->cannotBeEmpty() |
||
| 35 | ->info('Sets the default email address for all cron output to go to.') |
||
| 36 | ->example('[email protected]') |
||
| 37 | ->end() |
||
| 38 | ->scalarNode('path') |
||
| 39 | ->example('/usr/local/bin:/usr/bin:/bin') |
||
| 40 | ->info('Sets the path for all commands in the crontab.') |
||
| 41 | ->end() |
||
| 42 | ->scalarNode('executor') |
||
| 43 | ->cannotBeEmpty() |
||
| 44 | ->defaultValue('php') |
||
| 45 | ->example('php') |
||
| 46 | ->info('Allows you to specify a program that all commands should be passed to such as "/usr/local/bin/php".') |
||
| 47 | ->end() |
||
| 48 | ->scalarNode('console') |
||
| 49 | ->cannotBeEmpty() |
||
| 50 | ->defaultValue('%kernel.root_dir%/../bin/console') |
||
| 51 | ->example('%kernel.project_dir%/bin/console') |
||
| 52 | ->info('Allows you to specify the console that all commands should be passed to such as "bin/console".') |
||
| 53 | ->end() |
||
| 54 | ->scalarNode('shell') |
||
| 55 | ->cannotBeEmpty() |
||
| 56 | ->example('/bin/sh') |
||
| 57 | ->info('Allows you to specify which shell each program should be run with.') |
||
| 58 | ->end() |
||
| 59 | ->scalarNode('timezone') |
||
| 60 | ->example('Europe/Paris') |
||
| 61 | ->info('Allows you to add CRON_TZ which specifies the time zone specific for the cron table.') |
||
| 62 | ->end() |
||
| 63 | ->end() |
||
| 64 | ->end() |
||
| 65 | ->end(); |
||
| 66 | |||
| 67 | return $treeBuilder; |
||
| 68 | } |
||
| 69 | } |
||
| 70 |
This check looks for function calls that miss required arguments.