| Conditions | 3 |
| Paths | 1 |
| Total Lines | 77 |
| 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 |
||
| 55 | private function setupLocaleConfiguration(ArrayNodeDefinition $rootNode) |
||
| 56 | { |
||
| 57 | $rootNode |
||
| 58 | ->children() |
||
| 59 | ->arrayNode('locales') |
||
| 60 | ->info('The available application locales') |
||
| 61 | ->isRequired() |
||
| 62 | ->prototype('scalar') |
||
| 63 | ->validate() |
||
| 64 | ->ifTrue(function ($locale) { |
||
| 65 | return !is_string($locale); |
||
| 66 | }) |
||
| 67 | ->thenInvalid('Available application locales should be strings') |
||
| 68 | ->end() |
||
| 69 | ->end() |
||
| 70 | ->end() |
||
| 71 | ->scalarNode('default_locale') |
||
| 72 | ->info('The default application locale') |
||
| 73 | ->isRequired() |
||
| 74 | ->validate() |
||
| 75 | ->ifTrue(function ($locale) { |
||
| 76 | return !is_string($locale); |
||
| 77 | }) |
||
| 78 | ->thenInvalid('Default application locale should be a string') |
||
| 79 | ->end() |
||
| 80 | ->end() |
||
| 81 | ->scalarNode('locale_cookie_domain') |
||
| 82 | ->info('The domain for which the locale cookie is set') |
||
| 83 | ->isRequired() |
||
| 84 | ->validate() |
||
| 85 | ->ifTrue(function ($domain) { |
||
| 86 | return !is_string($domain); |
||
| 87 | }) |
||
| 88 | ->thenInvalid('Locale cookie domain should be a string') |
||
| 89 | ->end() |
||
| 90 | ->end() |
||
| 91 | ->scalarNode('locale_cookie_key') |
||
| 92 | ->info('The key for which the locale cookie value is set') |
||
| 93 | ->isRequired() |
||
| 94 | ->validate() |
||
| 95 | ->ifTrue(function ($key) { |
||
| 96 | return !is_string($key); |
||
| 97 | }) |
||
| 98 | ->thenInvalid('Locale cookie key should be a string') |
||
| 99 | ->end() |
||
| 100 | ->end() |
||
| 101 | ->scalarNode('locale_cookie_expires_in') |
||
| 102 | ->info('The time interval after which the locale cookie expires; null gives a session cookie') |
||
| 103 | ->isRequired() |
||
| 104 | ->validate() |
||
| 105 | ->ifTrue(function ($expiresIn) { |
||
| 106 | if ($expiresIn === null) { |
||
| 107 | return false; |
||
| 108 | } |
||
| 109 | |||
| 110 | if (!is_string($expiresIn)) { |
||
| 111 | return true; |
||
| 112 | } |
||
| 113 | |||
| 114 | $now = new DateTimeImmutable(); |
||
| 115 | $future = $now->modify($expiresIn); |
||
| 116 | |||
| 117 | return $now >= $future; |
||
| 118 | }) |
||
| 119 | ->thenInvalid('Locale cookie expiration should be null or a positive DateTime modifier string, for example "+2 months"') |
||
| 120 | ->end() |
||
| 121 | ->end() |
||
| 122 | ->booleanNode('locale_cookie_secure') |
||
| 123 | ->isRequired() |
||
| 124 | ->info('Whether or not the locale cookie should be secure') |
||
| 125 | ->end() |
||
| 126 | ->booleanNode('locale_cookie_http_only') |
||
| 127 | ->isRequired() |
||
| 128 | ->info('Whether or not the locale cookie should be HTTP only') |
||
| 129 | ->end() |
||
| 130 | ->end(); |
||
| 131 | } |
||
| 132 | |||
| 259 |