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

Primitive   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A fromValue() 0 3 1
A resolve() 0 5 1
A __construct() 0 3 1
A compile() 0 3 1
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