| Conditions | 11 |
| Paths | 8 |
| Total Lines | 38 |
| Code Lines | 22 |
| 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 |
||
| 72 | public function loadClassMetadata(ClassMetadataInterface $classMetadata) |
||
| 73 | { |
||
| 74 | if (!$this->initialized) { |
||
| 75 | $loaders = []; |
||
| 76 | |||
| 77 | foreach ($this->directories as $directory) { |
||
| 78 | $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory)); |
||
| 79 | |||
| 80 | foreach ($iterator as $file) { |
||
| 81 | if ($file->isDir()) { |
||
| 82 | continue; |
||
| 83 | } |
||
| 84 | |||
| 85 | switch ($file->getExtension()) { |
||
| 86 | case self::EXTENSION_JSON: |
||
| 87 | $loaders[] = new JsonClassMetadataLoader($file->getRealPath(), $this->typeParser); |
||
| 88 | break; |
||
| 89 | |||
| 90 | case self::EXTENSION_XML: |
||
| 91 | $loaders[] = new XmlClassMetadataLoader($file->getRealPath(), $this->typeParser); |
||
| 92 | break; |
||
| 93 | |||
| 94 | case self::EXTENSION_YAML: |
||
| 95 | $loaders[] = new YamlClassMetadataLoader($file->getRealPath(), $this->typeParser); |
||
| 96 | break; |
||
| 97 | } |
||
| 98 | } |
||
| 99 | } |
||
| 100 | |||
| 101 | if (!empty($loaders)) { |
||
| 102 | $this->loader = count($loaders) > 1 ? new ChainClassMetadataLoader($loaders) : array_shift($loaders); |
||
| 103 | } |
||
| 104 | |||
| 105 | $this->initialized = true; |
||
| 106 | } |
||
| 107 | |||
| 108 | return $this->loader !== null && $this->loader->loadClassMetadata($classMetadata); |
||
| 109 | } |
||
| 110 | } |
||
| 111 |