Driver   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 81.82%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 37
ccs 9
cts 11
cp 0.8182
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A config() 0 8 2
A getConfigPath() 0 12 2
1
<?php
2
3
namespace FlyingLuscas\BugNotifier\Drivers;
4
5
use FlyingLuscas\BugNotifier\Exceptions\DriverConfigPathNotFoundException;
6
7
abstract class Driver
8
{
9
    /**
10
     * Get the driver configurations.
11
     *
12
     * @param  string $name
13
     * @param  mixed  $default
14
     *
15
     * @return mixed
16
     */
17 6
    protected function config($name = null, $default = null)
18
    {
19 6
        if (is_null($name)) {
20
            return config($this->getConfigPath(), $default);
21
        }
22
23 6
        return config(sprintf('%s.%s', $this->getConfigPath(), $name), $default);
24
    }
25
26
    /**
27
     * Get the driver configuration path.
28
     *
29
     * @return string|null
30
     */
31 6
    private function getConfigPath()
32
    {
33 6
        $classname = class_basename(get_called_class());
34 6
        $config = strtolower(preg_replace('/driver$/i', null, $classname));
35 6
        $path = sprintf('bugnotifier.%s', $config);
36
37 6
        if (config($path, false) === false) {
38
            throw new DriverConfigPathNotFoundException;
39
        }
40
41 6
        return $path;
42
    }
43
}
44