| Conditions | 2 |
| Paths | 1 |
| Total Lines | 60 |
| Code Lines | 50 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 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 |
||
| 158 | private function createSmsConfiguration(ArrayNodeDefinition $root) |
||
| 159 | { |
||
| 160 | $root |
||
| 161 | ->children() |
||
| 162 | ->arrayNode('sms') |
||
| 163 | ->canBeDisabled() |
||
| 164 | ->info('SMS configuration') |
||
| 165 | ->isRequired() |
||
| 166 | ->children() |
||
| 167 | ->scalarNode('service') |
||
| 168 | ->info( |
||
| 169 | 'The ID of the SMS service used for sending SMS messages. ' . |
||
| 170 | 'Must implement "Surfnet\StepupBundle\Service\SmsService".' |
||
| 171 | ) |
||
| 172 | ->defaultValue(self::DEFAULT_SMS_SERVICE) |
||
| 173 | ->validate() |
||
| 174 | ->ifTrue(function ($value) { |
||
| 175 | return !is_string($value); |
||
| 176 | }) |
||
| 177 | ->thenInvalid('The SMS service ID must be specified using a string.') |
||
| 178 | ->end() |
||
| 179 | ->end() |
||
| 180 | ->scalarNode('originator') |
||
| 181 | ->info('Originator (sender) for SMS messages') |
||
| 182 | ->validate() |
||
| 183 | ->ifTrue(function ($value) { |
||
| 184 | return (!is_string($value) || !preg_match('~^[a-z0-9]{1,11}$~i', $value)); |
||
| 185 | }) |
||
| 186 | ->thenInvalid( |
||
| 187 | 'Invalid SMS originator specified: "%s". Must be a string matching ' |
||
| 188 | . '"~^[a-z0-9]{1,11}$~i".' |
||
| 189 | ) |
||
| 190 | ->end() |
||
| 191 | ->end() |
||
| 192 | ->integerNode('otp_expiry_interval') |
||
| 193 | ->info('After how many seconds an SMS challenge OTP expires') |
||
| 194 | ->validate() |
||
| 195 | ->ifTrue(function ($value) { |
||
| 196 | return $value <= 0; |
||
| 197 | }) |
||
| 198 | ->thenInvalid( |
||
| 199 | 'Invalid SMS challenge OTP expiry, must be one or more seconds.' |
||
| 200 | ) |
||
| 201 | ->end() |
||
| 202 | ->end() |
||
| 203 | ->integerNode('maximum_otp_requests') |
||
| 204 | ->info('How many challenges a user may request during a session') |
||
| 205 | ->validate() |
||
| 206 | ->ifTrue(function ($value) { |
||
| 207 | return $value <= 0; |
||
| 208 | }) |
||
| 209 | ->thenInvalid( |
||
| 210 | 'Maximum OTP requests has a minimum of 1' |
||
| 211 | ) |
||
| 212 | ->end() |
||
| 213 | ->end() |
||
| 214 | ->end() |
||
| 215 | ->end() |
||
| 216 | ->end(); |
||
| 217 | } |
||
| 218 | |||
| 238 |