<?php

declare (strict_types=1);
namespace PoP\GraphQLParser\Spec\Parser\Ast\ArgumentValue;

use PoP\GraphQLParser\Spec\Parser\Ast\AbstractAst;
use PoP\GraphQLParser\Spec\Parser\Location;
/** @internal */
class Literal extends AbstractAst implements \PoP\GraphQLParser\Spec\Parser\Ast\ArgumentValue\ArgumentValueAstInterface
{
    public function __construct(protected string|int|float|bool|null $value, Location $location)
    {
        parent::__construct($location);
    }
    protected function doAsQueryString() : string
    {
        return $this->getGraphQLQueryStringFormatter()->getLiteralAsQueryString($this->value);
    }
    protected function doAsASTNodeString() : string
    {
        return $this->getGraphQLQueryStringFormatter()->getLiteralAsQueryString($this->value);
    }
    /**
     * @return string|int|float|bool|null
     */
    public function getValue() : mixed
    {
        return $this->value;
    }
    /**
     * Indicate if a field equals another one based on its properties,
     * not on its object hash ID.
     */
    public function isEquivalentTo(\PoP\GraphQLParser\Spec\Parser\Ast\ArgumentValue\Literal $literal) : bool
    {
        return $this->getValue() === $literal->getValue();
    }
}
