GeneratorProxy::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
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 2
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 Yiisoft\Yii\Gii;
6
7
use Closure;
8
9
final class GeneratorProxy
10
{
11
    private ?GeneratorInterface $generator = null;
12
13
    /**
14
     * @psalm-param class-string<GeneratorInterface> $class
15
     */
16 8
    public function __construct(private readonly Closure $loader, private readonly string $class)
17
    {
18 8
    }
19
20
    /**
21
     * @return class-string<GeneratorInterface>
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string<GeneratorInterface> at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string<GeneratorInterface>.
Loading history...
22
     */
23 2
    public function getClass(): string
24
    {
25 2
        return $this->class;
26
    }
27
28 2
    public function loadGenerator(): GeneratorInterface
29
    {
30 2
        return $this->generator ??= ($this->loader)();
31
    }
32
}
33