| Conditions | 2 |
| Paths | 1 |
| Total Lines | 115 |
| Code Lines | 108 |
| Lines | 0 |
| Ratio | 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 |
||
| 161 | private function addFilesystemSection(ArrayNodeDefinition $node) |
||
| 162 | { |
||
| 163 | $node |
||
| 164 | ->children() |
||
| 165 | ->arrayNode('filesystem') |
||
| 166 | ->children() |
||
| 167 | ->arrayNode('local') |
||
| 168 | ->addDefaultsIfNotSet() |
||
| 169 | ->children() |
||
| 170 | ->scalarNode('directory')->defaultValue('%kernel.root_dir%/../web/uploads/media')->end() |
||
| 171 | ->scalarNode('create')->defaultValue(false)->end() |
||
| 172 | ->end() |
||
| 173 | ->end() |
||
| 174 | |||
| 175 | ->arrayNode('ftp') |
||
| 176 | ->children() |
||
| 177 | ->scalarNode('directory')->isRequired()->end() |
||
| 178 | ->scalarNode('host')->isRequired()->end() |
||
| 179 | ->scalarNode('username')->isRequired()->end() |
||
| 180 | ->scalarNode('password')->isRequired()->end() |
||
| 181 | ->scalarNode('port')->defaultValue(21)->end() |
||
| 182 | ->scalarNode('passive')->defaultValue(false)->end() |
||
| 183 | ->scalarNode('create')->defaultValue(false)->end() |
||
| 184 | ->scalarNode('mode')->defaultValue(defined('FTP_BINARY') ? FTP_BINARY : false)->end() |
||
| 185 | ->end() |
||
| 186 | ->end() |
||
| 187 | |||
| 188 | ->arrayNode('s3') |
||
| 189 | ->children() |
||
| 190 | ->scalarNode('directory')->defaultValue('')->end() |
||
| 191 | ->scalarNode('bucket')->isRequired()->end() |
||
| 192 | ->scalarNode('accessKey')->isRequired()->end() |
||
| 193 | ->scalarNode('secretKey')->isRequired()->end() |
||
| 194 | ->scalarNode('create')->defaultValue(false)->end() |
||
| 195 | ->scalarNode('storage') |
||
| 196 | ->defaultValue('standard') |
||
| 197 | ->validate() |
||
| 198 | ->ifNotInArray(array('standard', 'reduced')) |
||
| 199 | ->thenInvalid('Invalid storage type - "%s"') |
||
| 200 | ->end() |
||
| 201 | ->end() |
||
| 202 | ->scalarNode('cache_control')->defaultValue('')->end() |
||
| 203 | ->scalarNode('acl') |
||
| 204 | ->defaultValue('public') |
||
| 205 | ->validate() |
||
| 206 | ->ifNotInArray(array('private', 'public', 'open', 'auth_read', 'owner_read', 'owner_full_control')) |
||
| 207 | ->thenInvalid('Invalid acl permission - "%s"') |
||
| 208 | ->end() |
||
| 209 | ->end() |
||
| 210 | ->scalarNode('encryption') |
||
| 211 | ->defaultValue('') |
||
| 212 | ->validate() |
||
| 213 | ->ifNotInArray(array('aes256')) |
||
| 214 | ->thenInvalid('Invalid encryption type - "%s"') |
||
| 215 | ->end() |
||
| 216 | ->end() |
||
| 217 | ->scalarNode('region')->defaultValue('s3.amazonaws.com')->end() |
||
| 218 | ->arrayNode('meta') |
||
| 219 | ->useAttributeAsKey('name') |
||
| 220 | ->prototype('scalar') |
||
| 221 | ->end() |
||
| 222 | ->end() |
||
| 223 | ->end() |
||
| 224 | ->end() |
||
| 225 | |||
| 226 | ->arrayNode('mogilefs') |
||
| 227 | ->children() |
||
| 228 | ->scalarNode('domain')->isRequired()->end() |
||
| 229 | ->arrayNode('hosts') |
||
| 230 | ->prototype('scalar')->end() |
||
| 231 | ->isRequired() |
||
| 232 | ->end() |
||
| 233 | ->end() |
||
| 234 | ->end() |
||
| 235 | |||
| 236 | ->arrayNode('replicate') |
||
| 237 | ->children() |
||
| 238 | ->scalarNode('master')->isRequired()->end() |
||
| 239 | ->scalarNode('slave')->isRequired()->end() |
||
| 240 | ->end() |
||
| 241 | ->end() |
||
| 242 | ->arrayNode('openstack') |
||
| 243 | ->children() |
||
| 244 | ->scalarNode('url')->isRequired()->end() |
||
| 245 | ->arrayNode('secret') |
||
| 246 | ->children() |
||
| 247 | ->scalarNode('username')->isRequired()->end() |
||
| 248 | ->scalarNode('password')->isRequired()->end() |
||
| 249 | ->end() |
||
| 250 | ->end() |
||
| 251 | ->scalarNode('region')->end() |
||
| 252 | ->scalarNode('containerName')->defaultValue('media')->end() |
||
| 253 | ->scalarNode('create_container')->defaultValue(false)->end() |
||
| 254 | ->end() |
||
| 255 | ->end() |
||
| 256 | ->arrayNode('rackspace') |
||
| 257 | ->children() |
||
| 258 | ->scalarNode('url')->isRequired()->end() |
||
| 259 | ->arrayNode('secret') |
||
| 260 | ->children() |
||
| 261 | ->scalarNode('username')->isRequired()->end() |
||
| 262 | ->scalarNode('apiKey')->isRequired()->end() |
||
| 263 | ->end() |
||
| 264 | ->end() |
||
| 265 | ->scalarNode('region')->isRequired()->end() |
||
| 266 | ->scalarNode('containerName')->defaultValue('media')->end() |
||
| 267 | ->scalarNode('create_container')->defaultValue(false)->end() |
||
| 268 | ->end() |
||
| 269 | ->end() |
||
| 270 | ->end() |
||
| 271 | ->end() |
||
| 272 | ->end() |
||
| 273 | ->end() |
||
| 274 | ; |
||
| 275 | } |
||
| 276 | |||
| 482 |