

declare (strict_types=1);
<?php if (isset($namespace)): ?>
namespace <?=$namespace?>;
<?php endif ?>

use Axtiva\FlexibleGraphql\Generator\Exception\UnknownEnumValue;
use Axtiva\FlexibleGraphql\Type\EnumInterface;

/**
 * This code is @generated by axtiva/flexible-graphql-php
 * and will be regenerated. Do not edit it manually
 * PHP representation of graphql enum <?=$enum_name?><?=PHP_EOL?>
<?php if (isset($enum_description)): ?>
 * <?=$enum_description?><?=PHP_EOL?>
<?php endif ?>
 */
final class <?=$short_class_name?> implements EnumInterface
{
<?php foreach ($enums ?? [] as $enum): ?>
<?php if (isset($enum['description'])): ?>
    /**
     * <?=$enum['description']?><?=PHP_EOL?>
     */
<?php endif ?>
    public const <?=$enum['value']?> = '<?=$enum['value']?>';
<?php endforeach ?>
    public string $value;
    private static array $map = [
<?php foreach ($enums ?? [] as $enum): ?>
        self::<?=$enum['value']?> => true,
<?php endforeach ?>
    ];

    public function __construct($value)
    {
        if (!isset(self::$map[$value])) {
            throw new UnknownEnumValue(__CLASS__, $value);
        }
        $this->value = $value;
    }

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