Lazy::method()   A
last analyzed

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