| Conditions | 8 |
| Paths | 1 |
| Total Lines | 78 |
| Code Lines | 40 |
| 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 |
||
| 17 | public function register(Container $container) |
||
| 18 | { |
||
| 19 | $container['validator.loader.xml.files'] = function () { |
||
| 20 | return array(); |
||
| 21 | }; |
||
| 22 | |||
| 23 | $container['validator.loader.yaml.files'] = function () { |
||
| 24 | return array(); |
||
| 25 | }; |
||
| 26 | |||
| 27 | $container['validator.loader.annotation'] = function () { |
||
| 28 | if (class_exists('Doctrine\Common\Annotations\AnnotationReader')) { |
||
| 29 | return new AnnotationLoader(new AnnotationReader()); |
||
| 30 | } |
||
| 31 | |||
| 32 | return null; |
||
| 33 | }; |
||
| 34 | |||
| 35 | $container['validator.loader.staticmethod'] = function () { |
||
| 36 | return new StaticMethodLoader(); |
||
| 37 | }; |
||
| 38 | |||
| 39 | $container['validator.loader.xml'] = function () use ($container) { |
||
| 40 | $files = $container['validator.loader.xml.files']; |
||
| 41 | if ($files) { |
||
| 42 | return new XmlFilesLoader($files); |
||
| 43 | } |
||
| 44 | |||
| 45 | return null; |
||
| 46 | }; |
||
| 47 | |||
| 48 | $container['validator.loader.yaml'] = function () use ($container) { |
||
| 49 | $files = $container['validator.loader.yaml.files']; |
||
| 50 | if ($files) { |
||
| 51 | return new YamlFilesLoader($files); |
||
| 52 | } |
||
| 53 | |||
| 54 | return null; |
||
| 55 | }; |
||
| 56 | |||
| 57 | $container['validator.loaders'] = function () use ($container) { |
||
| 58 | $loaders = array(); |
||
| 59 | |||
| 60 | $annotationLoader = $container['validator.loader.annotation']; |
||
| 61 | |||
| 62 | if (null !== $annotationLoader) { |
||
| 63 | $loaders[] = $annotationLoader; |
||
| 64 | } |
||
| 65 | |||
| 66 | $staticMethodLoader = $container['validator.loader.staticmethod']; |
||
| 67 | |||
| 68 | if (null !== $staticMethodLoader) { |
||
| 69 | $loaders[] = $staticMethodLoader; |
||
| 70 | } |
||
| 71 | |||
| 72 | $xmlLoader = $container['validator.loader.xml']; |
||
| 73 | |||
| 74 | if (null !== $xmlLoader) { |
||
| 75 | $loaders[] = $xmlLoader; |
||
| 76 | } |
||
| 77 | |||
| 78 | $yamlLoader = $container['validator.loader.yaml']; |
||
| 79 | |||
| 80 | if (null !== $yamlLoader) { |
||
| 81 | $loaders[] = $yamlLoader; |
||
| 82 | } |
||
| 83 | |||
| 84 | return $loaders; |
||
| 85 | }; |
||
| 86 | |||
| 87 | $container['validator.mapping.class_metadata_factory'] = function () use ($container) { |
||
| 88 | $loaders = $container['validator.loaders']; |
||
| 89 | |||
| 90 | return new LazyLoadingMetadataFactory( |
||
| 91 | new LoaderChain($loaders) |
||
| 92 | ); |
||
| 93 | }; |
||
| 94 | } |
||
| 95 | } |
||
| 96 |