<?php

namespace Torchlight\Engine;

use Phiki\Grammar\Grammar;
use Phiki\Grammar\ParsedGrammar;

class PreparedGrammar
{
    public function __construct(
        /**
         * @readonly
         */
        public Grammar|ParsedGrammar|string $grammar,
        /**
         * @readonly
         */
        public string $vanityLabel = '',
    ) {}

    public function getName(): string
    {
        if (is_string($this->grammar)) {
            return $this->grammar;
        }

        return $this->grammar->name ?? '';
    }
}
