BugsnagService   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 9
c 1
b 0
f 0
dl 0
loc 14
ccs 9
cts 9
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A boot() 0 12 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Sulao\ThinkBugsnag;
6
7
use Bugsnag\Client;
8
use Bugsnag\Handler;
9
use think\Service;
10
11
class BugsnagService extends Service
12
{
13 1
    public function boot()
14
    {
15 1
        $config = $this->app->config->get('bugsnag', []) + ['api_key' => null];
16 1
        $bugsnag = Client::make($config['api_key']);
17 1
        foreach ($config as $key => $value) {
18 1
            $method = 'set' . implode('', array_map('ucfirst', explode('_', $key)));
19 1
            if (method_exists($bugsnag, $method) && !is_null($value)) {
20 1
                $bugsnag->$method($value);
21
            }
22
        }
23 1
        Handler::register($bugsnag);
24 1
        $this->app->bind('bugsnag', $bugsnag);
25
    }
26
}
27