Completed
Push — master ( 1a6c14...1a0ee4 )
by Andrey
02:15
created

CallableItemBuilder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 19
ccs 8
cts 8
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A build() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Borodulin\Container\Autowire;
6
7
use Borodulin\Container\Autowire\Item\CallableItem;
8
9
class CallableItemBuilder
10
{
11
    /**
12
     * @var ItemProvider
13
     */
14
    private $itemProvider;
15
16 3
    public function __construct(ItemProvider $itemProvider)
17
    {
18 3
        $this->itemProvider = $itemProvider;
19 3
    }
20
21 3
    public function build(callable $callable): CallableItem
22
    {
23 3
        $reflection = new \ReflectionFunction(\Closure::fromCallable($callable));
24 3
        $args = (new DependencyBuilder($this->itemProvider, new ClassItemBuilder($this->itemProvider)))
25 3
            ->buildParameters($reflection->getParameters());
26
27 3
        return new CallableItem($callable, $args);
28
    }
29
}
30