Completed
Push — master ( 92f687...a0bc1f )
by Andrii
13:55
created

Component   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 15
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 12 4
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 (!empty(SentrySdk::getCurrentHub()->getClient())) {
21
            return;
22
        }
23
        $params = Yii::$app->params;
24
        if (empty($params['sentry.dsn']) || empty($params['sentry.enabled'])) {
25
            return;
26
        }
27
28
        \Sentry\init(['dsn' => $params['sentry.dsn']]);
29
    }
30
}
31