Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| RbacMiddlewareFactory | |
100.00% |
6 / 6 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| forPermission | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | // ╔════════════════════════════════════════════════════════════╗ |
| 4 | // ║ MIT Licence (#Expat) - https://opensource.org/licenses/MIT ║ |
| 5 | // ║ Copyright 2026 Frederic Poeydomenge <dyno@phexium.com> ║ |
| 6 | // ╚════════════════════════════════════════════════════════════╝ |
| 7 | |
| 8 | declare(strict_types=1); |
| 9 | |
| 10 | namespace AppDemo\Shared\Infrastructure; |
| 11 | |
| 12 | use AppDemo\Shared\Application\Middleware\RbacPermissionMiddleware; |
| 13 | use AppDemo\Shared\Domain\Interface\RbacPermissionServiceInterface; |
| 14 | use Psr\Http\Message\ResponseFactoryInterface; |
| 15 | |
| 16 | final readonly class RbacMiddlewareFactory |
| 17 | { |
| 18 | public function __construct( |
| 19 | private RbacPermissionServiceInterface $rbacPermissionService, |
| 20 | private ResponseFactoryInterface $responseFactory |
| 21 | ) {} |
| 22 | |
| 23 | public function forPermission(string $permission): RbacPermissionMiddleware |
| 24 | { |
| 25 | return new RbacPermissionMiddleware( |
| 26 | $this->rbacPermissionService, |
| 27 | $this->responseFactory, |
| 28 | $permission |
| 29 | ); |
| 30 | } |
| 31 | } |