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

Arguments::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 8
ccs 7
cts 7
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;
5
6
use Innmind\Compose\{
7
    Arguments as Container,
8
    Definition
9
};
10
use Innmind\Immutable\Set;
11
12
final class Arguments
13
{
14
    private $arguments;
15
16 7
    public function __construct(Container $arguments)
17
    {
18 7
        $this->arguments = $arguments
19 7
            ->all()
20 7
            ->reduce(
21 7
                Set::of(Argument::class),
22 7
                static function(Set $arguments, Definition\Argument $argument): Set {
23 3
                    return $arguments->add($argument->compile());
24 7
                }
25
            );
26 7
    }
27
28 5
    public function __toString(): string
29
    {
30 5
        return (string) $this->arguments->join("\n\n");
31
    }
32
}
33