Completed
Push — master ( ac3cad...7fabe3 )
by Artem
03:23
created

RollbarHelperTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 33
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A sendExceptionToRollbar() 0 8 2
A sendMessageToRollbar() 0 8 2
1
<?php
2
/*
3
 * This file is part of the FreshCommonApiBundle
4
 *
5
 * (c) Artem Genvald <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Fresh\CommonApiBundle\Helper\Logger;
12
13
/**
14
 * RollbarHelperTrait.
15
 *
16
 * @author Artem Genvald <[email protected]>
17
 */
18
trait RollbarHelperTrait
19
{
20
    use BaseLoggerTrait;
21
22
    /**
23
     * Send exception to Rollbar.
24
     *
25
     * @param \Exception $e Exception
26
     */
27
    protected function sendExceptionToRollbar(\Exception $e)
28
    {
29
        if ($this->has('ftrrtf_rollbar.notifier')) {
30
            /** @var \Ftrrtf\Rollbar\Notifier $rollbarNotifier */
31
            $rollbarNotifier = $this->get('ftrrtf_rollbar.notifier');
32
            $rollbarNotifier->reportException($e);
33
        }
34
    }
35
36
    /**
37
     * Send message to Rollbar.
38
     *
39
     * @param string $message Message
40
     * @param string $level   Level
41
     */
42
    protected function sendMessageToRollbar($message, $level)
43
    {
44
        if ($this->has('ftrrtf_rollbar.notifier')) {
45
            /** @var \Ftrrtf\Rollbar\Notifier $rollbarNotifier */
46
            $rollbarNotifier = $this->get('ftrrtf_rollbar.notifier');
47
            $rollbarNotifier->reportMessage($message, $level);
48
        }
49
    }
50
}
51