Passed
Push — develop ( 9b8c4e...79e7ae )
by Andrea Marco
03:34 queued 14s
created

Generator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cerbero\LaravelEnum\Services;
6
7
use Cerbero\Enum\Data\GeneratingEnum;
8
use Cerbero\Enum\Enums\Backed;
9
use Cerbero\Enum\Services\Generator as BaseGenerator;
10
11
/**
12
 * The enums generator.
13
 */
14
final class Generator extends BaseGenerator
15
{
16
    /**
17
     * Instantiate the class.
18
     *
19
     * @param class-string<\UnitEnum> $namespace
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string<\UnitEnum> at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string<\UnitEnum>.
Loading history...
20
     * @param string[] $cases
21
     */
22 4
    public function __construct(string $namespace, array $cases, private readonly Backed $backed)
23
    {
24 4
        $this->enum = new GeneratingEnum($namespace, $backed->back($cases));
25
    }
26
27
    /**
28
     * Retrieve the path of the stub.
29
     */
30 4
    protected function stub(): string
31
    {
32 4
        return $this->backed->is(Backed::bitwise)
33 2
            ? __DIR__ . '/../../stubs/bitwise.stub'
34 4
            : __DIR__ . '/../../stubs/enum.stub';
35
    }
36
}
37