Completed
Push — master ( e0728e...80525c )
by Sébastien
05:21
created

BoundCallback::addDependencyForCallParameter()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.2
c 0
b 0
f 0
cc 4
eloc 9
nc 3
nop 4
1
<?php
2
3
namespace Sebdesign\SM\Callback;
4
5
use Illuminate\Container\BoundMethod;
6
use SM\Event\TransitionEvent;
7
8
class BoundCallback extends BoundMethod
9
{
10
    /**
11
     * {@inheritDoc}
12
     */
13
    protected static function addDependencyForCallParameter($container, $parameter,
14
                                                            array &$parameters, &$dependencies)
15
    {
16
        // If the call parameter is a type-hinted object,
17
        // add the dependency from the first parameter
18
        // that matches the type-hint.
19
        if ($parameter->getClass()) {
20
            foreach ($parameters as $key => $value) {
21
                if ($parameter->getClass()->isInstance($value)) {
22
                    $dependencies[] = $value;
23
                    unset($parameters[$key]);
24
                    return;
25
                }
26
            }
27
        }
28
29
        parent::addDependencyForCallParameter($container, $parameter, $parameters, $dependencies);
30
    }
31
}
32