| Conditions | 2 |
| Paths | 1 |
| Total Lines | 87 |
| Code Lines | 81 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 21 | public function getConfigTreeBuilder(): TreeBuilder |
||
| 22 | { |
||
| 23 | $treeBuilder = new TreeBuilder('zikula_users'); |
||
| 24 | |||
| 25 | $treeBuilder->getRootNode() |
||
| 26 | ->children() |
||
| 27 | ->booleanNode('allow_self_deletion') |
||
| 28 | ->info('Allow users to delete themselves.') |
||
| 29 | ->defaultFalse() |
||
| 30 | ->end() |
||
| 31 | ->arrayNode('registration') |
||
|
|
|||
| 32 | ->info('Registration settings.') |
||
| 33 | ->addDefaultsIfNotSet() |
||
| 34 | ->children() |
||
| 35 | ->booleanNode('enabled') |
||
| 36 | ->info('Allow new user account registrations.') |
||
| 37 | ->defaultTrue() |
||
| 38 | ->end() |
||
| 39 | ->scalarNode('disabled_reason') |
||
| 40 | ->info('Statement displayed if registration disabled.') |
||
| 41 | ->defaultValue('Sorry! New user registration is currently disabled.') |
||
| 42 | ->end() |
||
| 43 | ->scalarNode('admin_notification_mail') |
||
| 44 | ->info('E-mail address to notify of registrations (leave blank for no notifications).') |
||
| 45 | ->defaultNull() |
||
| 46 | ->validate() |
||
| 47 | ->ifTrue(static function ($v) { |
||
| 48 | return null !== $v && !filter_var($v, FILTER_VALIDATE_EMAIL); |
||
| 49 | }) |
||
| 50 | ->thenInvalid('Please enter a valid mail address.') |
||
| 51 | ->end() |
||
| 52 | ->end() |
||
| 53 | ->end() |
||
| 54 | ->end() |
||
| 55 | ->booleanNode('display_registration_date') |
||
| 56 | ->info('Display the user\'s registration date.') |
||
| 57 | ->defaultFalse() |
||
| 58 | ->end() |
||
| 59 | ->arrayNode('avatar') |
||
| 60 | ->info('Avatar settings.') |
||
| 61 | ->addDefaultsIfNotSet() |
||
| 62 | ->children() |
||
| 63 | ->scalarNode('image_path') |
||
| 64 | ->info('Path to user\'s avatar images.') |
||
| 65 | ->defaultValue('public/uploads/avatar') |
||
| 66 | ->end() |
||
| 67 | ->scalarNode('default_image') |
||
| 68 | ->info('Default avatar image (used as fallback).') |
||
| 69 | ->defaultValue('gravatar.jpg') |
||
| 70 | ->end() |
||
| 71 | ->booleanNode('gravatar_enabled') |
||
| 72 | ->info('Allow usage of Gravatar.') |
||
| 73 | ->defaultTrue() |
||
| 74 | ->end() |
||
| 75 | ->arrayNode('uploads') |
||
| 76 | ->info('Allow uploading custom avatar images.') |
||
| 77 | ->canBeEnabled() |
||
| 78 | ->children() |
||
| 79 | ->booleanNode('shrink_large_images') |
||
| 80 | ->info('Shrink large images to maximum dimensions.') |
||
| 81 | ->defaultTrue() |
||
| 82 | ->end() |
||
| 83 | ->integerNode('max_size') |
||
| 84 | ->info('Max. avatar filesize in bytes.') |
||
| 85 | ->defaultValue(12000) |
||
| 86 | ->min(1) |
||
| 87 | ->end() |
||
| 88 | ->integerNode('max_width') |
||
| 89 | ->info('Max. avatar width in pixels.') |
||
| 90 | ->defaultValue(80) |
||
| 91 | ->min(1) |
||
| 92 | ->max(9999) |
||
| 93 | ->end() |
||
| 94 | ->integerNode('max_height') |
||
| 95 | ->info('Max. avatar height in pixels.') |
||
| 96 | ->defaultValue(80) |
||
| 97 | ->min(1) |
||
| 98 | ->max(9999) |
||
| 99 | ->end() |
||
| 100 | ->end() |
||
| 101 | ->end() |
||
| 102 | ->end() |
||
| 103 | ->end() |
||
| 104 | ->end() |
||
| 105 | ; |
||
| 106 | |||
| 107 | return $treeBuilder; |
||
| 108 | } |
||
| 110 |