Component   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 16 5
1
<?php
2
/**
3
 * Health monitoring for Yii2 applications
4
 *
5
 * @link      https://github.com/hiqdev/yii2-monitoring
6
 * @package   yii2-monitoring
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\yii2\monitoring;
12
13
use Sentry\SentrySdk;
14
use Yii;
15
16
class Component extends \yii\base\Component
17
{
18
    public function init()
19
    {
20
        if (!class_exists(SentrySdk::class)) {
21
            return;
22
        }
23
        if (!empty(SentrySdk::getCurrentHub()->getClient())) {
24
            return;
25
        }
26
27
        $params = Yii::$app->params;
28
        if (empty($params['sentry.dsn']) || empty($params['sentry.enabled'])) {
29
            return;
30
        }
31
32
        \Sentry\init(['dsn' => $params['sentry.dsn']]);
33
    }
34
}
35