Passed
Pull Request — master (#1)
by Dmitriy
08:59
created

SentryIntegration::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Yiisoft\Yii\Sentry\Middleware;
5
6
use Psr\Http\Message\ResponseInterface;
7
use Psr\Http\Message\ServerRequestInterface;
8
use Psr\Http\Server\MiddlewareInterface;
0 ignored issues
show
Bug introduced by
The type Psr\Http\Server\MiddlewareInterface 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\Server\RequestHandlerInterface;
0 ignored issues
show
Bug introduced by
The type Psr\Http\Server\RequestHandlerInterface 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...
10
use Sentry\State\HubInterface;
11
use Throwable;
12
13
final class SentryIntegration implements MiddlewareInterface
14
{
15
    private HubInterface $hub;
16
17
    public function __construct(HubInterface $hub)
18
    {
19
        $this->hub = $hub;
20
    }
21
22
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
23
    {
24
        try {
25
            return $handler->handle($request);
26
        } catch (Throwable $e) {
27
            $this->hub->captureException($e);
28
            throw $e;
29
        }
30
    }
31
}
32