| Total Complexity | 3 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Coverage | 75% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | final class AttributeHelper |
||
| 10 | { |
||
| 11 | public static function hasAttribute(\ReflectionProperty|\ReflectionClass|\ReflectionMethod|\ReflectionFunction|\ReflectionParameter $target, string $attributeClass): bool |
||
| 12 | { |
||
| 13 | return null !== self::getAttribute($target, $attributeClass); |
||
| 14 | } |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @template T |
||
| 18 | * |
||
| 19 | * @param class-string<T> $attributeClass |
||
|
|
|||
| 20 | * |
||
| 21 | * @return null|T |
||
| 22 | */ |
||
| 23 | 15 | public static function getAttribute(\ReflectionProperty|\ReflectionClass|\ReflectionMethod|\ReflectionFunction|\ReflectionParameter $target, string $attributeClass): ?object |
|
| 24 | { |
||
| 25 | 15 | return ArrayList::collect(self::getAttributes($target, $attributeClass))->firstElement()->get(); |
|
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @template T |
||
| 30 | * |
||
| 31 | * @param class-string<T> $attributeClass |
||
| 32 | * |
||
| 33 | * @return T[] |
||
| 34 | */ |
||
| 35 | 32 | public static function getAttributes(\ReflectionProperty|\ReflectionClass|\ReflectionMethod|\ReflectionFunction|\ReflectionParameter $target, string $attributeClass): array |
|
| 40 | ; |
||
| 41 | } |
||
| 42 | } |
||
| 43 |