Completed
Push — sam-rework ( a5f68e...28559d )
by Andrii
10:44
created

CallableDefinition   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 4
dl 0
loc 16
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
4
namespace yii\di\definitions;
5
6
use Psr\Container\ContainerInterface;
7
use yii\di\contracts\DefinitionInterface;
8
9
class CallableDefinition implements DefinitionInterface
10
{
11
    private $method;
12
13
    public function __construct(callable $method)
14
    {
15
        $this->method = $method;
16
    }
17
18
    /**
19
     * @param ContainerInterface $container
20
     * @param array $params
21
     */
22
    public function resolve(ContainerInterface $container, array $params = [])
23
    {
24
        return $container->getInjector()->invoke($this->method, $params);
0 ignored issues
show
Bug introduced by
The method getInjector() does not exist on Psr\Container\ContainerInterface. It seems like you code against a sub-type of Psr\Container\ContainerInterface such as yii\di\Container or yii\di\AbstractContainer. ( Ignorable by Annotation )

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

24
        return $container->/** @scrutinizer ignore-call */ getInjector()->invoke($this->method, $params);
Loading history...
25
    }
26
}
27