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

DeferredFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 0
c 1
b 0
f 0
dl 0
loc 4
ccs 1
cts 1
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
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