| Total Complexity | 8 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | #[Immutable] |
||
| 11 | final class ClassHelper |
||
| 12 | { |
||
| 13 | final public const DEFAULT_SHORT_NAME = 'InvalidClassName'; |
||
| 14 | |||
| 15 | private function __construct() |
||
| 17 | } |
||
| 18 | |||
| 19 | public static function getShortName(string|object $target): string |
||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @template T |
||
| 26 | * |
||
| 27 | * @param class-string<T>|T $target |
||
|
|
|||
| 28 | * |
||
| 29 | * @return null|\ReflectionClass<T> |
||
| 30 | */ |
||
| 31 | public static function getReflectionClass(string|object $target): ?\ReflectionClass |
||
| 32 | { |
||
| 33 | try { |
||
| 34 | return $target instanceof \ReflectionClass ? $target : new \ReflectionClass($target); |
||
| 35 | } catch (\ReflectionException) { |
||
| 36 | return null; |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @template T |
||
| 42 | * |
||
| 43 | * @param class-string<T>|T $target |
||
| 44 | * |
||
| 45 | * @return null|\ReflectionClass<T> |
||
| 46 | */ |
||
| 47 | public static function getParentReflectionClass(string|object $target): ?\ReflectionClass |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @template T |
||
| 54 | * |
||
| 55 | * @param class-string<T> $attributeClass |
||
| 56 | * |
||
| 57 | * @return \Iterator<\ReflectionAttribute<T>> |
||
| 58 | */ |
||
| 59 | public static function getReflectionAttributes(string|object $target, string $attributeClass): iterable |
||
| 62 | } |
||
| 63 | } |
||
| 64 |