JsonDetectionMiddleware::process()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
c 0
b 0
f 0
nc 2
nop 2
dl 0
loc 6
rs 10
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
Bug introduced by
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