Passed
Pull Request — master (#941)
by Aleksei
13:25 queued 04:54
created

DeferredFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 5
c 1
b 0
f 0
dl 0
loc 17
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __toString() 0 6 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Core\Config;
6
7
/**
8
 * Factory that can be resolved later.
9
 */
10
final class DeferredFactory extends Binding
11
{
12
    /**
13
     * @param array{0: object|non-empty-string, 1: non-empty-string, ...} $factory
0 ignored issues
show
Documentation Bug introduced by
The doc comment object|non-empty-string, 1: non-empty-string, at position 2 could not be parsed: Unknown type name 'non-empty-string' at position 2 in object|non-empty-string, 1: non-empty-string,.
Loading history...
14
     */
15 399
    public function __construct(
16
        public readonly array $factory,
17
        public readonly bool $singleton = false,
18
    ) {
19 399
    }
20
21 298
    public function __toString(): string
22
    {
23 298
        return sprintf(
24 298
            "Deferred factory '%s'->%s()",
25 298
            \is_string($this->factory[0]) ? $this->factory[0] : \get_debug_type($this->factory[0]),
26 298
            $this->factory[1],
27 298
        );
28
    }
29
}
30