Completed
Push — develop ( 15ec3c...8b62a8 )
by Baptiste
02:19
created

Primitive::compile()   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
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Compose\Definition\Service\Argument;
5
6
use Innmind\Compose\{
7
    Definition\Service\Argument,
8
    Definition\Service\Arguments,
9
    Services,
10
    Compilation\Service\Argument as CompiledArgument,
11
    Compilation\Service\Argument\Primitive as CompiledPrimitive
12
};
13
use Innmind\Immutable\StreamInterface;
14
15
final class Primitive implements Argument
16
{
17
    private $value;
18
19 32
    public function __construct($value)
20
    {
21 32
        $this->value = $value;
22 32
    }
23
24
    /**
25
     * {@inheritdoc}
26
     */
27 17
    public static function fromValue($value, Arguments $arguments): Argument
28
    {
29 17
        return new self($value);
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35 12
    public function resolve(
36
        StreamInterface $built,
37
        Services $services
38
    ): StreamInterface {
39 12
        return $built->add($this->value);
40
    }
41
42 4
    public function compile(): CompiledArgument
43
    {
44 4
        return new CompiledPrimitive($this->value);
45
    }
46
}
47