Passed
Pull Request — master (#4)
by Dmitriy
09:08 queued 07:14
created

SentryProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 17
ccs 0
cts 8
cp 0
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 15 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Sentry;
6
7
use Psr\Log\LoggerInterface;
8
use Sentry\ClientBuilder;
9
use Sentry\Options;
10
use Sentry\SentrySdk;
11
use Sentry\State\HubInterface;
12
use Sentry\Transport\TransportFactoryInterface;
13
use Yiisoft\Di\Container;
14
use Yiisoft\Di\Support\ServiceProvider;
15
16
final class SentryProvider extends ServiceProvider
17
{
18
    public function register(Container $container): void
19
    {
20
        $options = $container->get(Options::class);
21
22
        $clientBuilder = new ClientBuilder($options);
23
        $clientBuilder
24
            ->setTransportFactory($container->get(TransportFactoryInterface::class))
25
            ->setLogger($container->get(LoggerInterface::class));
26
27
        $client = $clientBuilder->getClient();
28
29
        $hub = $container->get(HubInterface::class);
30
        $hub->bindClient($client);
31
32
        SentrySdk::setCurrentHub($hub);
33
    }
34
}
35