Automattic\WooCommerce\Vendor\GraphQL\Utils
SchemaPrinter::printEnum
Method of the class: SchemaPrinter{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = SchemaPrinter::printEnum( $type, $options ): string;
- $type(EnumType) (required)
- .
- $options(array) (required)
- .
SchemaPrinter::printEnum() SchemaPrinter::printEnum code WC 10.9.1
protected static function printEnum(EnumType $type, array $options): string
{
$values = [];
$firstInBlock = true;
$valueDefinitions = $type->getValues();
if (isset($options['sortEnumValues']) && $options['sortEnumValues']) {
usort($valueDefinitions, static fn (EnumValueDefinition $left, EnumValueDefinition $right): int => $left->name <=> $right->name);
}
foreach ($valueDefinitions as $value) {
$values[] = static::printDescription($options, $value, ' ', $firstInBlock)
. ' '
. $value->name
. static::printDeprecated($value);
$firstInBlock = false;
}
return static::printDescription($options, $type)
. "enum {$type->name}"
. static::printBlock($values);
}