GeneratorProxy   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 4
c 1
b 0
f 0
dl 0
loc 22
ccs 6
cts 6
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getClass() 0 3 1
A __construct() 0 2 1
A loadGenerator() 0 3 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