Completed
Push — master ( 748c89...d24f56 )
by Schlaefer
06:53 queued 03:34
created

Plugin::onPluginsLoaded()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3.2621

Importance

Changes 0
Metric Value
cc 3
eloc 12
nc 3
nop 1
dl 0
loc 16
ccs 9
cts 13
cp 0.6923
crap 3.2621
rs 9.4285
c 0
b 0
f 0
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 31
    public function registerErrorHandler()
29
    {
30 31
        switch ($this->settings['handler']) {
31 31
            case Plugin::HANDLER_DEVELOPMENT:
32 31
                $handler = new Development($this->settings);
33 31
                break;
34
            case Plugin::HANDLER_ERROR_LOG:
35
                $handler = new ErrorLog($this->settings['error_log_file']);
36
                break;
37
            default:
38
                return;
39
        }
40 31
        ServiceLocator::registerService('Phile_ErrorHandler', $handler);
41 31
    }
42
}
43