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

Parameter::raw()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Compose\Compilation\Dependency;
5
6
use Innmind\Compose\{
7
    Definition\Name,
8
    Compilation\MethodName
9
};
10
11
final class Parameter
12
{
13
    private $name;
14
    private $value;
15
16 6
    private function __construct(Name $name, string $value)
17
    {
18 6
        $this->name = $name;
19 6
        $this->value = $value;
20 6
    }
21
22 4
    public static function raw(Name $name, $primitive): self
23
    {
24 4
        return new self(
25 4
            $name,
26 4
            var_export($primitive, true)
27
        );
28
    }
29
30 4
    public static function reference(Name $name, Name $reference): self
31
    {
32 4
        return new self(
33 4
            $name,
34 4
            sprintf('$this->%s()', new MethodName($reference))
35
        );
36
    }
37
38 5
    public function __toString(): string
39
    {
40 5
        return sprintf('->put(\'%s\', %s)', $this->name, $this->value);
41
    }
42
}
43