Issues (43)

Classes/Middleware/JsonDetectionMiddleware.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lochmueller\LanguageDetection\Middleware;
6
7
use Lochmueller\LanguageDetection\Handler\Exception\AbstractHandlerException;
8
use Lochmueller\LanguageDetection\Handler\JsonDetectionHandler;
0 ignored issues
show
The type Lochmueller\LanguageDete...er\JsonDetectionHandler was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Psr\Http\Message\ResponseInterface;
10
use Psr\Http\Message\ServerRequestInterface;
11
use Psr\Http\Server\MiddlewareInterface;
12
use Psr\Http\Server\RequestHandlerInterface;
13
14
class JsonDetectionMiddleware implements MiddlewareInterface
15
{
16
    public function __construct(protected JsonDetectionHandler $jsonDetectionHandler) {}
17
18
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
19
    {
20
        try {
21
            return $this->jsonDetectionHandler->handle($request);
22
        } catch (AbstractHandlerException $exception) {
23
            return $handler->handle($request);
24
        }
25
    }
26
}
27