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

Component::init()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 4
nc 3
nop 0
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