| Conditions | 1 |
| Paths | 1 |
| Total Lines | 64 |
| 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 |
||
| 30 | public function getConfigTreeBuilder() { |
||
| 31 | |||
| 32 | $assets = ConfigurationHelper::loadYamlConfig(__DIR__, "assets"); |
||
| 33 | $plugins = $assets["assets"]["wbw.core.asset.core"]["plugins"]; |
||
| 34 | |||
| 35 | $treeBuilder = new TreeBuilder(WBWCoreExtension::EXTENSION_ALIAS); |
||
| 36 | |||
| 37 | $rootNode = ConfigurationHelper::getRootNode($treeBuilder, WBWCoreExtension::EXTENSION_ALIAS); |
||
| 38 | $rootNode |
||
| 39 | ->children() |
||
| 40 | ->booleanNode("commands")->defaultTrue()->info("Load commands")->end() |
||
| 41 | ->booleanNode("event_listeners")->defaultTrue()->info("Load event listeners")->end() |
||
| 42 | ->booleanNode("providers")->defaultTrue()->info("Load providers")->end() |
||
| 43 | ->booleanNode("twig")->defaultTrue()->info("Load Twig extensions")->end() |
||
| 44 | ->arrayNode("quote_providers")->addDefaultsIfNotSet() |
||
| 45 | ->children() |
||
| 46 | ->booleanNode("worlds_wisdom")->defaultFalse()->info("Load World's wisdom")->end() |
||
| 47 | ->end() |
||
| 48 | ->end() |
||
| 49 | ->booleanNode("security_event_listener")->defaultFalse()->info("Load Security event listener")->end() |
||
| 50 | ->arrayNode("plugins")->info("Core plug-ins") |
||
| 51 | ->prototype("scalar") |
||
| 52 | ->validate() |
||
| 53 | ->ifNotInArray(array_keys($plugins)) |
||
| 54 | ->thenInvalid("The Core plug-in %s is not supported. Please choose one of " . json_encode(array_keys($plugins))) |
||
| 55 | ->end() |
||
| 56 | ->end() |
||
| 57 | ->end() |
||
| 58 | ->arrayNode("locales")->addDefaultsIfNotSet() |
||
| 59 | ->children() |
||
| 60 | ->variableNode("jquery_select2")->defaultValue("en")->info("jQuery Select2 locale") |
||
| 61 | ->validate() |
||
| 62 | ->ifNotInArray($plugins["jquery_select2"]["locales"]) |
||
| 63 | ->thenInvalid("The jQuery Select2 locale %s is not supported. Please choose one of " . json_encode($plugins["jquery_select2"]["locales"])) |
||
| 64 | ->end() |
||
| 65 | ->end() |
||
| 66 | ->end() |
||
| 67 | ->end() |
||
| 68 | ->arrayNode("themes")->addDefaultsIfNotSet() |
||
| 69 | ->children() |
||
| 70 | ->variableNode("syntax_highlighter")->defaultValue("Default")->info("SyntaxHighlighter theme") |
||
| 71 | ->validate() |
||
| 72 | ->ifNotInArray($plugins["syntax_highlighter"]["themes"]) |
||
| 73 | ->thenInvalid("The SyntaxHighlighter theme %s is not supported. Please choose one of " . json_encode($plugins["syntax_highlighter"]["themes"])) |
||
| 74 | ->end() |
||
| 75 | ->end() |
||
| 76 | ->end() |
||
| 77 | ->end() |
||
| 78 | ->arrayNode("brushes") |
||
| 79 | ->children() |
||
| 80 | ->arrayNode("syntax_highlighter")->info("SyntaxHighlighter brushes") |
||
| 81 | ->prototype("scalar") |
||
| 82 | ->validate() |
||
| 83 | ->ifNotInArray($plugins["syntax_highlighter"]["brushes"]) |
||
| 84 | ->thenInvalid("The SyntaxHighlighter brush %s is not supported. Please choose one of " . json_encode($plugins["syntax_highlighter"]["brushes"])) |
||
| 85 | ->end() |
||
| 86 | ->end() |
||
| 87 | ->end() |
||
| 88 | ->end() |
||
| 89 | ->end() |
||
| 90 | ->end(); |
||
| 91 | |||
| 92 | return $treeBuilder; |
||
| 93 | } |
||
| 94 | } |
||
| 95 |