Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| GetMethodAttribute | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getReflectionMethod | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | namespace Apie\StorageMetadata\Attributes; |
| 3 | |
| 4 | use Attribute; |
| 5 | use ReflectionClass; |
| 6 | use ReflectionMethod; |
| 7 | |
| 8 | #[Attribute(Attribute::TARGET_PROPERTY)] |
| 9 | class GetMethodAttribute |
| 10 | { |
| 11 | /** |
| 12 | * @param class-string<object>|null $declaredClass |
| 13 | */ |
| 14 | public function __construct( |
| 15 | public readonly string $methodName, |
| 16 | public readonly ?string $declaredClass = null, |
| 17 | public readonly bool $allowLargeStrings = false |
| 18 | ) { |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * @template T of object |
| 23 | * @param ReflectionClass<T> $targetClass |
| 24 | * @param T $instance |
| 25 | */ |
| 26 | public function getReflectionMethod(ReflectionClass $targetClass, object $instance): ?ReflectionMethod |
| 27 | { |
| 28 | return ($this->declaredClass ? new ReflectionClass($this->declaredClass) : $targetClass)->getMethod($this->methodName); |
| 29 | } |
| 30 | } |