| Conditions | 19 |
| Paths | 3612 |
| Total Lines | 48 |
| Code Lines | 29 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 40 | private function getEntityConfiguration(ClassMetadata $metadata): ?array |
||
| 41 | { |
||
| 42 | $annotation = null; |
||
| 43 | $auditableAnnotation = null; |
||
| 44 | $securityAnnotation = null; |
||
| 45 | $reflection = $metadata->getReflectionClass(); |
||
| 46 | |||
| 47 | // Check that we have an Entity annotation or attribute |
||
| 48 | $attributes = \PHP_VERSION_ID >= 80000 && method_exists($reflection, 'getAttributes') ? $reflection->getAttributes(Entity::class) : null; |
||
| 49 | if (\is_array($attributes) && \count($attributes) > 0) { |
||
| 50 | $annotation = $attributes[0]->newInstance(); |
||
| 51 | } elseif (null !== $this->reader) { |
||
| 52 | $annotation = $this->reader->getClassAnnotation($reflection, Entity::class); |
||
| 53 | } |
||
| 54 | |||
| 55 | if (null === $annotation) { |
||
| 56 | return null; |
||
| 57 | } |
||
| 58 | |||
| 59 | // Check that we have an Auditable annotation or attribute |
||
| 60 | $attributes = \PHP_VERSION_ID >= 80000 && method_exists($reflection, 'getAttributes') ? $reflection->getAttributes(Auditable::class) : null; |
||
| 61 | if (\is_array($attributes) && \count($attributes) > 0) { |
||
| 62 | $auditableAnnotation = $attributes[0]->newInstance(); |
||
| 63 | } elseif (null !== $this->reader) { |
||
| 64 | $auditableAnnotation = $this->reader->getClassAnnotation($reflection, Auditable::class); |
||
| 65 | } |
||
| 66 | |||
| 67 | if (null === $auditableAnnotation) { |
||
| 68 | return null; |
||
| 69 | } |
||
| 70 | |||
| 71 | // Check that we have a Security annotation or attribute |
||
| 72 | $attributes = \PHP_VERSION_ID >= 80000 && method_exists($reflection, 'getAttributes') ? $reflection->getAttributes(Security::class) : null; |
||
| 73 | if (\is_array($attributes) && \count($attributes) > 0) { |
||
| 74 | $securityAnnotation = $attributes[0]->newInstance(); |
||
| 75 | } elseif (null !== $this->reader) { |
||
| 76 | $securityAnnotation = $this->reader->getClassAnnotation($reflection, Security::class); |
||
| 77 | } |
||
| 78 | |||
| 79 | $roles = null === $securityAnnotation ? null : [Security::VIEW_SCOPE => $securityAnnotation->view]; |
||
| 80 | |||
| 81 | // Are there any Ignore annotation or attribute? |
||
| 82 | $ignoredColumns = $this->getAllProperties($reflection); |
||
| 83 | |||
| 84 | return [ |
||
| 85 | 'ignored_columns' => $ignoredColumns, |
||
| 86 | 'enabled' => $auditableAnnotation->enabled, |
||
| 87 | 'roles' => $roles, |
||
| 88 | ]; |
||
| 116 |