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

SentryIntegration::bound()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
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