Automattic\WooCommerce\Vendor\GraphQL\Type\Definition

IDType::serializepublicWC 1.0

Method of the class: IDType{}

No Hooks.

Returns

null. Nothing (null).

Usage

$IDType = new IDType();
$IDType->serialize( $value ): string;
$value(required)
.

IDType::serialize() code WC 10.9.1

public function serialize($value): string
{
    $canCast = is_string($value)
        || is_int($value)
        || (is_object($value) && method_exists($value, '__toString'));

    if (! $canCast) {
        $notID = Utils::printSafe($value);
        throw new SerializationError("ID cannot represent a non-string and non-integer value: {$notID}");
    }

    return (string) $value;
}