Completed
Push — develop ( f8d1c0...c6d734 )
by Baptiste
02:31
created

Construct   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 25
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A fromString() 0 3 1
A __construct() 0 3 1
A __invoke() 0 5 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Compose\Definition\Service\Constructor;
5
6
use Innmind\Compose\Definition\Service\Constructor;
7
use Innmind\Immutable\Str;
8
9
final class Construct implements Constructor
10
{
11
    private $value;
12
13 35
    private function __construct(string $value)
14
    {
15 35
        $this->value = $value;
16 35
    }
17
18
    /**
19
     * {@inheritdoc}
20
     */
21 35
    public static function fromString(Str $value): Constructor
22
    {
23 35
        return new self((string) $value);
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29 16
    public function __invoke(...$arguments): object
30
    {
31 16
        $class = (string) $this->value;
32
33 16
        return new $class(...$arguments);
34
    }
35
}
36