Passed
Push — develop ( 9ae090...ce9409 )
by Schlaefer
42s
created

Plugin   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 63.64%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 30
ccs 7
cts 11
cp 0.6364
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A registerErrorHandler() 0 14 3
1
<?php
2
/**
3
 * @link http://philecms.github.io/
4
 * @license http://opensource.org/licenses/MIT
5
 * @package Phile\Plugin\Phile\ErrorHandler
6
 */
7
8
namespace Phile\Plugin\Phile\ErrorHandler;
9
10
use Phile\Core\ServiceLocator;
11
use Phile\Plugin\AbstractPlugin;
12
13
class Plugin extends AbstractPlugin
14
{
15
    public const HANDLER_ERROR_LOG = 'error_log';
16
17
    public const HANDLER_DEVELOPMENT = 'development';
18
19
    protected $events = ['plugins_loaded' => 'registerErrorHandler'];
20
21
    protected $settings = [
22
        'handler' => self::HANDLER_DEVELOPMENT,
23
        'editor' => null,
24
        'level' => -1,
25
        'error_log_file' => null
26
    ];
27
28 29
    public function registerErrorHandler()
29
    {
30 29
        switch ($this->settings['handler']) {
31 29
            case Plugin::HANDLER_DEVELOPMENT:
32 29
                $handler = new Development($this->settings);
33 29
                break;
34
            case Plugin::HANDLER_ERROR_LOG:
35
                $handler = new ErrorLog($this->settings['error_log_file']);
36
                break;
37
            default:
38
                return;
39
        }
40 29
        ServiceLocator::registerService('Phile_ErrorHandler', $handler);
41 29
    }
42
}
43