Automattic\WooCommerce\Vendor\GraphQL\Utils
SchemaPrinter::printArgs
Method of the class: SchemaPrinter{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = SchemaPrinter::printArgs( $options, $args, $indentation ): string;
- $options(array) (required)
- .
- $args(array) (required)
- .
- $indentation(string)
- .
Default:''
SchemaPrinter::printArgs() SchemaPrinter::printArgs code WC 10.9.1
protected static function printArgs(array $options, array $args, string $indentation = ''): string
{
if ($args === []) {
return '';
}
if (isset($options['sortArguments']) && $options['sortArguments']) {
usort($args, static fn (Argument $left, Argument $right): int => $left->name <=> $right->name);
}
$allArgsWithoutDescription = true;
foreach ($args as $arg) {
$description = $arg->description;
if ($description !== null && $description !== '') {
$allArgsWithoutDescription = false;
break;
}
}
if ($allArgsWithoutDescription) {
return '('
. implode(
', ',
array_map(
[static::class, 'printInputValue'],
$args
)
)
. ')';
}
$argsStrings = [];
$firstInBlock = true;
$previousHasDescription = false;
foreach ($args as $arg) {
$hasDescription = $arg->description !== null;
if ($previousHasDescription && ! $hasDescription) {
$argsStrings[] = '';
}
$argsStrings[] = static::printDescription($options, $arg, ' ' . $indentation, $firstInBlock)
. ' '
. $indentation
. static::printInputValue($arg);
$firstInBlock = false;
$previousHasDescription = $hasDescription;
}
return "(\n"
. implode("\n", $argsStrings)
. "\n"
. $indentation
. ')';
}