| Total Complexity | 7 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | final class Entity |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @param string $entity |
||
| 14 | * @return null|string |
||
| 15 | * @throws \Doctrine\Common\Annotations\AnnotationException |
||
| 16 | * @throws \ReflectionException |
||
| 17 | */ |
||
| 18 | public static function getEntityIdName(string $entity): ?string |
||
| 19 | { |
||
| 20 | $name = ''; |
||
| 21 | $reflectionClassName = new \ReflectionClass($entity); |
||
| 22 | foreach ($reflectionClassName->getProperties() as $property) { |
||
| 23 | /** @var Id $id */ |
||
| 24 | $id = (new AnnotationReader()) |
||
| 25 | ->getPropertyAnnotation($property, Id::class); |
||
| 26 | if (!empty($id)) { |
||
| 27 | $name = $property->getName(); |
||
| 28 | break; |
||
| 29 | } |
||
| 30 | } |
||
| 31 | |||
| 32 | return $name; |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @param string $entity |
||
| 37 | * @return string |
||
| 38 | * @throws \Doctrine\Common\Annotations\AnnotationException |
||
| 39 | * @throws \ReflectionException |
||
| 40 | */ |
||
| 41 | public static function getEntityIdType(string $entity): string |
||
| 61 | } |
||
| 62 | } |
||
| 63 |