Completed
Push — develop ( fe7998...59b49f )
by Baptiste
01:41
created

Tunnel   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 29
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 7 1
A fromValue() 0 3 1
A __construct() 0 4 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Compose\Definition\Service\Argument;
5
6
use Innmind\Compose\{
7
    Definition\Name,
8
    Definition\Service\Argument,
9
    Definition\Service\Arguments,
10
    Services,
11
    Exception\LogicException
12
};
13
use Innmind\Immutable\StreamInterface;
14
15
final class Tunnel implements Argument
16
{
17
    private $dependency;
18
    private $argument;
19
20 9
    public function __construct(Name $dependency, Argument $argument)
21
    {
22 9
        $this->dependency = $dependency;
23 9
        $this->argument = $argument;
24 9
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29 1
    public static function fromValue($value, Arguments $arguments): Argument
30
    {
31 1
        throw new LogicException('Can\'t be used outside Service::tunnel()');
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 2
    public function resolve(
38
        StreamInterface $built,
39
        Services $services
40
    ): StreamInterface {
41
        return $services
42 2
            ->dependencies()
43 2
            ->extract($this->dependency, $built, $this->argument);
44
    }
45
}
46