| Conditions | 1 |
| Paths | 1 |
| Total Lines | 88 |
| Code Lines | 77 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| Bugs | 0 | Features | 3 |
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 |
||
| 26 | public function getConfigTreeBuilder() |
||
| 27 | { |
||
| 28 | $treeBuilder = new TreeBuilder(); |
||
| 29 | $rootNode = $treeBuilder->root('open_conext_profile'); |
||
| 30 | |||
| 31 | $rootNode |
||
| 32 | ->children() |
||
| 33 | ->scalarNode('engine_block_entity_id') |
||
| 34 | ->info('The EntityID of EngineBlock') |
||
| 35 | ->isRequired() |
||
| 36 | ->validate() |
||
| 37 | ->ifTrue(function ($entityId) { |
||
| 38 | return !is_string($entityId); |
||
| 39 | }) |
||
| 40 | ->thenInvalid('EngineBlock EntityID should be a string') |
||
| 41 | ->end() |
||
| 42 | ->end() |
||
| 43 | ->arrayNode('locales') |
||
| 44 | ->info('The available application locales') |
||
| 45 | ->isRequired() |
||
| 46 | ->prototype('scalar') |
||
| 47 | ->validate() |
||
| 48 | ->ifTrue(function ($locale) { |
||
| 49 | return !is_string($locale); |
||
| 50 | }) |
||
| 51 | ->thenInvalid('Available application locales should be strings') |
||
| 52 | ->end() |
||
| 53 | ->end() |
||
| 54 | ->end() |
||
| 55 | ->scalarNode('default_locale') |
||
| 56 | ->info('The default application locale') |
||
| 57 | ->isRequired() |
||
| 58 | ->validate() |
||
| 59 | ->ifTrue(function ($locale) { |
||
| 60 | return !is_string($locale); |
||
| 61 | }) |
||
| 62 | ->thenInvalid('Default application locale should be a string') |
||
| 63 | ->end() |
||
| 64 | ->end() |
||
| 65 | ->scalarNode('locale_cookie_domain') |
||
| 66 | ->info('The domain for which the locale cookie is set') |
||
| 67 | ->isRequired() |
||
| 68 | ->validate() |
||
| 69 | ->ifTrue(function ($domain) { |
||
| 70 | return !is_string($domain); |
||
| 71 | }) |
||
| 72 | ->thenInvalid('Locale cookie domain should be a string') |
||
| 73 | ->end() |
||
| 74 | ->end() |
||
| 75 | ->scalarNode('locale_cookie_key') |
||
| 76 | ->info('The key for which the locale cookie value is set') |
||
| 77 | ->isRequired() |
||
| 78 | ->validate() |
||
| 79 | ->ifTrue(function ($key) { |
||
| 80 | return !is_string($key); |
||
| 81 | }) |
||
| 82 | ->thenInvalid('Locale cookie key should be a string') |
||
| 83 | ->end() |
||
| 84 | ->end() |
||
| 85 | ->arrayNode('attribute_support') |
||
| 86 | ->isRequired() |
||
| 87 | ->children() |
||
| 88 | ->scalarNode('email_to') |
||
| 89 | ->info('Email address to which attributes are sent') |
||
| 90 | ->isRequired() |
||
| 91 | ->validate() |
||
| 92 | ->ifTrue(function ($email) { |
||
| 93 | return !is_string($email); |
||
| 94 | }) |
||
| 95 | ->thenInvalid('Email address to which attributes are sent should be a string') |
||
| 96 | ->end() |
||
| 97 | ->end() |
||
| 98 | ->scalarNode('email_from') |
||
| 99 | ->info('mail address from which attributes are sent') |
||
| 100 | ->isRequired() |
||
| 101 | ->validate() |
||
| 102 | ->ifTrue(function ($email) { |
||
| 103 | return !is_string($email); |
||
| 104 | }) |
||
| 105 | ->thenInvalid('Email address from which attributes are sent should be a string') |
||
| 106 | ->end() |
||
| 107 | ->end() |
||
| 108 | ->end() |
||
| 109 | ->end() |
||
| 110 | ->end(); |
||
| 111 | |||
| 112 | return $treeBuilder; |
||
| 113 | } |
||
| 114 | } |
||
| 115 |