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

Lazy::method()   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\Compilation\Service\Argument;
5
6
use Innmind\Compose\Compilation\{
7
    Service\Argument,
8
    MethodName
9
};
10
11
final class Lazy implements Argument
12
{
13
    private $argument;
14
15 12
    public function __construct(Argument $argument)
16
    {
17 12
        $this->argument = $argument;
18 12
    }
19
20 1
    public function method(): MethodName
21
    {
22 1
        return $this->argument->method();
23
    }
24
25 7
    public function __toString(): string
26
    {
27 7
        if (!$this->argument instanceof Reference) {
28 6
            return (string) $this->argument;
29
        }
30
31
        return <<<PHP
32
new \\Innmind\\Compose\\Lazy(function() {
33 3
    return {$this->argument};
34
})
35
PHP;
36
    }
37
}
38