Merge   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 92.86%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 26
ccs 13
cts 14
cp 0.9286
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A __toString() 0 9 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Compose\Compilation\Service\Constructor;
5
6
use Innmind\Compose\{
7
    Compilation\Service\Constructor,
8
    Compilation\Service\Argument
9
};
10
use Innmind\Immutable\Stream;
11
12
final class Merge implements Constructor
13
{
14
    private $arguments;
15
16 3
    public function __construct(
17
        Argument $argument1,
18
        Argument $argument2,
19
        Argument ...$arguments
20
    ) {
21 3
        $this->arguments = Stream::of(
22 3
            Argument::class,
23 3
            $argument1,
24 3
            $argument2,
25
            ...$arguments
26
        );
27 3
    }
28
29 1
    public function __toString(): string
30
    {
31
        return $this
32 1
            ->arguments
33 1
            ->drop(1)
34 1
            ->reduce(
35 1
                (string) $this->arguments->first(),
36 1
                static function(string $code, Argument $argument): string {
37 1
                    return sprintf("%s\n->merge(%s)", $code, $argument);
38 1
                }
39
            );
40
    }
41
}
42