| Total Complexity | 5 |
| Total Lines | 29 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | final class AccessChecker implements MiddlewareInterface |
||
| 17 | { |
||
| 18 | private ?string $permission = null; |
||
| 19 | |||
| 20 | public function __construct( |
||
| 21 | private ResponseFactoryInterface $responseFactory, |
||
| 22 | private UserService $userService |
||
| 23 | ) { |
||
| 24 | } |
||
| 25 | |||
| 26 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
||
| 27 | { |
||
| 28 | if ($this->permission === null) { |
||
| 29 | throw new InvalidArgumentException('Permission not set.'); |
||
| 30 | } |
||
| 31 | |||
| 32 | if (!$this->userService->hasPermission($this->permission)) { |
||
| 33 | return $this->responseFactory->createResponse(Status::FORBIDDEN); |
||
| 34 | } |
||
| 35 | |||
| 36 | return $handler->handle($request); |
||
| 37 | } |
||
| 38 | |||
| 39 | public function withPermission(string $permission): self |
||
| 45 | } |
||
| 46 | } |
||
| 47 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths