| Total Complexity | 9 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | final class ClassHelper |
||
| 11 | { |
||
| 12 | public static function isNotBuiltinAndExists(string $className): bool |
||
| 13 | { |
||
| 14 | return class_exists($className) && !empty((new \ReflectionClass($className))->getNamespaceName()); |
||
| 15 | } |
||
| 16 | |||
| 17 | public static function getShortName(string $className): string |
||
| 18 | { |
||
| 19 | try { |
||
| 20 | return (new \ReflectionClass($className))->getShortName(); |
||
| 21 | } catch (\ReflectionException) { |
||
| 22 | return $className; |
||
| 23 | } |
||
| 24 | } |
||
| 25 | |||
| 26 | public static function isNameContains(string $className, string ...$haystack): bool |
||
| 31 | } |
||
| 32 | |||
| 33 | public static function getPropertyMapping(string $className): array |
||
| 34 | { |
||
| 35 | try { |
||
| 36 | $properties = (new \ReflectionClass($className))->getProperties(); |
||
| 37 | } catch (\ReflectionException) { |
||
| 38 | $properties = []; |
||
| 39 | } |
||
| 40 | |||
| 41 | $map = static fn (\ReflectionProperty $p): array => [ |
||
| 42 | SerializerHelper::getSerializedNameAttribute($p)->getSerializedName() => $p->getType()?->getName(), |
||
|
|
|||
| 43 | ]; |
||
| 44 | |||
| 45 | return array_merge(...array_map($map, $properties)); |
||
| 46 | } |
||
| 47 | |||
| 48 | /** @return \ReflectionParameter[] */ |
||
| 49 | public static function getMethodParameters(string $class, string $method): array |
||
| 55 | } |
||
| 56 | } |
||
| 57 | } |
||
| 58 |