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

DispatcherInjector::build()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 2
eloc 5
nc 2
nop 0
1
<?php /** MicroDispatcherInjector */
2
3
namespace Micro\Base;
4
5
/**
6
 * Class DispatcherInjector
7
 *
8
 * @author Oleg Lunegov <[email protected]>
9
 * @link https://github.com/linpax/microphp-framework
10
 * @copyright Copyright &copy; 2013 Oleg Lunegov
11
 * @license /LICENSE
12
 * @package Micro
13
 * @subpackage Base
14
 * @version 1.0
15
 * @since 1.0
16
 */
17
class DispatcherInjector extends Injector
18
{
19
    /**
20
     * @return IDispatcher
21
     * @throws Exception
22
     */
23
    public function build()
24
    {
25
        $dispatcher = parent::get('dispatcher');
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...
26
27
        if (!($dispatcher instanceof IDispatcher)) {
28
            throw new Exception('Component `dispatcher` not configured');
29
        }
30
31
        return $dispatcher;
32
    }
33
}