MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: /home/cafsindia/lead_cafsinfotech_in/vendor/webonyx/graphql-php/src/Error/CoercionError.php
<?php declare(strict_types=1);

namespace GraphQL\Error;

use GraphQL\Utils\Utils;

/**
 * @phpstan-type InputPath list<string|int>
 */
class CoercionError extends Error
{
    /** @var InputPath|null */
    public ?array $inputPath;

    /** @var mixed whatever invalid value was passed */
    public $invalidValue;

    /**
     * @param InputPath|null $inputPath
     * @param mixed $invalidValue whatever invalid value was passed
     *
     * @return static
     */
    public static function make(
        string $message,
        ?array $inputPath,
        $invalidValue,
        ?\Throwable $previous = null
    ): self {
        $instance = new static($message, null, null, [], null, $previous);
        $instance->inputPath = $inputPath;
        $instance->invalidValue = $invalidValue;

        return $instance;
    }

    public function printInputPath(): ?string
    {
        if ($this->inputPath === null) {
            return null;
        }

        $path = '';
        foreach ($this->inputPath as $segment) {
            $path .= is_int($segment)
                ? "[{$segment}]"
                : ".{$segment}";
        }

        return $path;
    }

    public function printInvalidValue(): string
    {
        return Utils::printSafeJson($this->invalidValue);
    }
}