Automattic\WooCommerce\Vendor\GraphQL\Type\Definition
EnumType::serialize
Method of the class: EnumType{}
No Hooks.
Returns
null. Nothing (null).
Usage
$EnumType = new EnumType(); $EnumType->serialize( $value );
- $value(required)
- .
EnumType::serialize() EnumType::serialize code WC 11.1.2
public function serialize($value)
{
$lookup = $this->getValueLookup();
if (isset($lookup[$value])) {
return $lookup[$value]->name;
}
if ($value instanceof \BackedEnum) {
return $value->name;
}
if ($value instanceof \UnitEnum) {
return $value->name;
}
$safeValue = Utils::printSafe($value);
throw new SerializationError("Cannot serialize value as enum: {$safeValue}");
}