Passed
Branch master (748c89)
by Schlaefer
02:28
created

Plugin   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 69.23%

Importance

Changes 0
Metric Value
dl 0
loc 29
ccs 9
cts 13
cp 0.6923
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A onPluginsLoaded() 0 16 3
1
<?php
2
/**
3
 * Plugin class
4
 */
5
namespace Phile\Plugin\Phile\ErrorHandler;
6
7
use Phile\Core\Router;
8
use Phile\Core\ServiceLocator;
9
use Phile\Plugin\AbstractPlugin;
10
use Phile\Plugin\Phile\ErrorHandler\Development;
11
use Phile\Plugin\Phile\ErrorHandler\ErrorLog;
12
13
/**
14
 * Class Plugin
15
 * Default Phile parser plugin for Markdown
16
 *
17
 * @author  PhileCMS
18
 * @link    https://philecms.com
19
 * @license http://opensource.org/licenses/MIT
20
 * @package Phile\Plugin\Phile\ParserMarkdown
21
 */
22
class Plugin extends AbstractPlugin
23
{
24
    const HANDLER_ERROR_LOG = 'error_log';
25
    const HANDLER_DEVELOPMENT = 'development';
26
27
    protected $events = ['plugins_loaded' => 'onPluginsLoaded'];
28
29
    /**
30
     * called on 'plugins_loaded' event
31
     *
32
     * @param  null $data
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $data is correct as it would always require null to be passed?
Loading history...
33
     * @throws \Phile\Exception\ServiceLocatorException
34
     */
35 28
    public function onPluginsLoaded($data = null)
0 ignored issues
show
Unused Code introduced by
The parameter $data is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

35
    public function onPluginsLoaded(/** @scrutinizer ignore-unused */ $data = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
    {
37 28
        $this->settings['base_url'] = (new Router)->getBaseUrl();
38 28
        switch ($this->settings['handler']) {
39 28
            case Plugin::HANDLER_ERROR_LOG:
40
                ServiceLocator::registerService(
41
                    'Phile_ErrorHandler',
42
                    new ErrorLog
43
                );
44
                break;
45 28
            case Plugin::HANDLER_DEVELOPMENT:
46 28
                ServiceLocator::registerService(
47 28
                    'Phile_ErrorHandler',
48 28
                    new Development($this->settings)
49
                );
50 28
                break;
51
        }
52 28
    }
53
}
54