Passed
Push — master ( 50c542...726283 )
by Zing
09:42
created

SentryIntegration   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 8
c 1
b 0
f 0
dl 0
loc 26
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A captureException() 0 4 2
A getAbstract() 0 7 2
A bound() 0 3 1
A getInstance() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Zing\LaravelSentry\Support;
6
7
use Illuminate\Container\Container;
8
use Sentry\Laravel\ServiceProvider;
9
use Sentry\State\Hub;
10
11
class SentryIntegration
12
{
13
    public static function getAbstract(): string
14
    {
15
        if (class_exists(ServiceProvider::class)) {
16
            return ServiceProvider::$abstract;
17
        }
18
19
        return 'sentry';
20
    }
21
22
    public static function bound(): bool
23
    {
24
        return Container::getInstance()->bound(static::getAbstract());
25
    }
26
27
    public static function captureException($exception): void
28
    {
29
        if (static::bound()) {
30
            static::getInstance()->captureException($exception);
31
        }
32
    }
33
34
    public static function getInstance(): Hub
35
    {
36
        return Container::getInstance()->make(static::getAbstract());
37
    }
38
}
39