Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| AllowAnonymousAttributeHandler | |
100.00% |
4 / 4 |
|
100.00% |
3 / 3 |
5 | |
100.00% |
1 / 1 |
| __construct | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | |||||
| attributeClass | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| targets | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| handle | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Dynart\Micro\AttributeHandler; |
| 4 | |
| 5 | use Dynart\Micro\Attribute\AllowAnonymous; |
| 6 | use Dynart\Micro\AttributeHandlerInterface; |
| 7 | use Dynart\Micro\JwtAuthInterface; |
| 8 | |
| 9 | class AllowAnonymousAttributeHandler implements AttributeHandlerInterface { |
| 10 | |
| 11 | public function __construct(private JwtAuthInterface $jwtAuth) {} |
| 12 | |
| 13 | public function attributeClass(): string { |
| 14 | return AllowAnonymous::class; |
| 15 | } |
| 16 | |
| 17 | public function targets(): array { |
| 18 | return [AttributeHandlerInterface::TARGET_METHOD]; |
| 19 | } |
| 20 | |
| 21 | public function handle(string $className, mixed $subject, object $attribute): void { |
| 22 | if ($subject instanceof \ReflectionMethod) { |
| 23 | $this->jwtAuth->addAllowAnonymous($className, $subject->getName()); |
| 24 | } |
| 25 | } |
| 26 | } |