Passed
Push — master ( c4286f...5969a6 )
by Oleg
04:27
created

LoggerInjector::get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 2
eloc 5
nc 2
nop 0
1
<?php /** MicroLoggerInjector */
2
3
namespace Micro\Logger;
4
5
use Micro\Base\Exception;
6
use Micro\Base\Injector;
7
8
/**
9
 * Class LoggerInjector
10
 *
11
 * @author Oleg Lunegov <[email protected]>
12
 * @link https://github.com/linpax/microphp-framework
13
 * @copyright Copyright &copy; 2013 Oleg Lunegov
14
 * @license /LICENSE
15
 * @package Micro
16
 * @subpackage Logger
17
 * @version 1.0
18
 * @since 1.0
19
 */
20
class LoggerInjector extends Injector
21
{
22
    /**
23
     * @access public
24
     * @return Logger
25
     * @throws Exception
26
     */
27
    public function build()
28
    {
29
        $logger = parent::get('logger');
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (get() instead of build()). Are you sure this is correct? If so, you might want to change this to $this->get().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
30
31
        if (!($logger instanceof Logger)) {
32
            throw new Exception('Component `logger` not configured');
33
        }
34
35
        return $logger;
36
    }
37
38
}