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

Tunnel::fromValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 2
crap 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