| Conditions | 10 |
| Paths | 80 |
| Total Lines | 33 |
| 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 |
||
| 36 | public function loadMetadataForClass(\ReflectionClass $class) |
||
| 37 | { |
||
| 38 | $classMetadata = new ClassMetadata($class->name); |
||
| 39 | $classMetadata->fileResources[] = $class->getFileName(); |
||
| 40 | |||
| 41 | foreach ($this->reader->getClassAnnotations($class) as $annotation) { |
||
| 42 | if ($annotation instanceof NamespaceNode) { |
||
| 43 | $classMetadata->addGraphNamespace($annotation); |
||
| 44 | } |
||
| 45 | |||
| 46 | if ($annotation instanceof GraphNode) { |
||
| 47 | $classMetadata->addGraphMetadata($annotation, new MetadataValue($annotation->value)); |
||
| 48 | } |
||
| 49 | } |
||
| 50 | |||
| 51 | foreach ($class->getProperties() as $property) { |
||
| 52 | foreach ($this->reader->getPropertyAnnotations($property) as $annotation) { |
||
| 53 | if ($annotation instanceof GraphNode) { |
||
| 54 | $classMetadata->addGraphMetadata($annotation, new PropertyMetadata($class->name, $property->name)); |
||
| 55 | } |
||
| 56 | } |
||
| 57 | } |
||
| 58 | |||
| 59 | foreach ($class->getMethods() as $method) { |
||
| 60 | foreach ($this->reader->getMethodAnnotations($method) as $annotation) { |
||
| 61 | if ($annotation instanceof GraphNode) { |
||
| 62 | $classMetadata->addGraphMetadata($annotation, new MethodMetadata($class->name, $method->name)); |
||
| 63 | } |
||
| 64 | } |
||
| 65 | } |
||
| 66 | |||
| 67 | return $classMetadata; |
||
| 68 | } |
||
| 69 | } |
||
| 70 |