cerbero90 /
enum
| 1 | <?php |
||||
| 2 | |||||
| 3 | declare(strict_types=1); |
||||
| 4 | |||||
| 5 | namespace Cerbero\Enum\Data; |
||||
| 6 | |||||
| 7 | use function Cerbero\Enum\backingType; |
||||
| 8 | use function Cerbero\Enum\namespaceToPath; |
||||
| 9 | use function Cerbero\Enum\splitNamespace; |
||||
| 10 | |||||
| 11 | /** |
||||
| 12 | * The enum being generated. |
||||
| 13 | */ |
||||
| 14 | class GeneratingEnum |
||||
| 15 | { |
||||
| 16 | /** |
||||
| 17 | * The namespace of the enum. |
||||
| 18 | */ |
||||
| 19 | public readonly string $namespace; |
||||
| 20 | |||||
| 21 | /** |
||||
| 22 | * The name of the enum. |
||||
| 23 | */ |
||||
| 24 | public readonly string $name; |
||||
| 25 | |||||
| 26 | /** |
||||
| 27 | * The absolute path of the enum. |
||||
| 28 | */ |
||||
| 29 | public readonly string $path; |
||||
| 30 | |||||
| 31 | /** |
||||
| 32 | * Whether the enum exists. |
||||
| 33 | */ |
||||
| 34 | public readonly bool $exists; |
||||
| 35 | |||||
| 36 | /** |
||||
| 37 | * The backing type, if backed. |
||||
| 38 | */ |
||||
| 39 | public readonly ?string $backingType; |
||||
| 40 | |||||
| 41 | /** |
||||
| 42 | * Instantiate the class. |
||||
| 43 | * |
||||
| 44 | * @param class-string<\UnitEnum> $fullNamespace |
||||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||||
| 45 | * @param array<string, string|int|null> $cases |
||||
| 46 | */ |
||||
| 47 | 4 | public function __construct(public readonly string $fullNamespace, public readonly array $cases) |
|||
| 48 | { |
||||
| 49 | 4 | [$this->namespace, $this->name] = splitNamespace($fullNamespace); |
|||
|
0 ignored issues
–
show
|
|||||
| 50 | |||||
| 51 | 4 | $this->path = namespaceToPath($fullNamespace); |
|||
|
0 ignored issues
–
show
|
|||||
| 52 | |||||
| 53 | 4 | $this->exists = enum_exists($fullNamespace); |
|||
|
0 ignored issues
–
show
The function
enum_exists was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 54 | |||||
| 55 | 4 | $this->backingType = backingType(reset($cases)); |
|||
|
0 ignored issues
–
show
|
|||||
| 56 | } |
||||
| 57 | } |
||||
| 58 |