henzeb/enumhancer

View on GitHub
src/Helpers/EnumProxy.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php

namespace Henzeb\Enumhancer\Helpers;

use Stringable;
use UnitEnum;

class EnumProxy implements Stringable
{
    public readonly string $name;
    public readonly string $value;

    public function __construct(UnitEnum $enum, bool $keepValueCase)
    {
        $this->name = $enum->name;
        $this->value = (string)EnumValue::value($enum, $keepValueCase);
    }

    public function __toString(): string
    {
        return $this->value;
    }
}