Automattic\WooCommerce\Vendor\GraphQL\Utils

SchemaPrinter::printDescriptionprotected staticWC 1.0

Method of the class: SchemaPrinter{}

No Hooks.

Returns

null. Nothing (null).

Usage

$result = SchemaPrinter::printDescription( $options, $def, $indentation, $firstInBlock ): string;
$options(array) (required)
.
$def((Type&NamedType)|Directive|EnumValueDefinition|Argument|FieldDefinition|InputObjectField|Schema) (required)
.
$indentation(string)
.
Default: ''
$firstInBlock(true|false)
.
Default: true

SchemaPrinter::printDescription() code WC 10.9.1

protected static function printDescription(array $options, $def, string $indentation = '', bool $firstInBlock = true): string
{
    $description = $def->description;
    if ($description === null) {
        return '';
    }

    $prefix = $indentation !== '' && ! $firstInBlock
        ? "\n{$indentation}"
        : $indentation;

    if (count(Utils::splitLines($description)) === 1) {
        $description = json_encode($description, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
    } else {
        $description = BlockString::print($description);
        $description = $indentation !== ''
            ? str_replace("\n", "\n{$indentation}", $description)
            : $description;
    }

    return "{$prefix}{$description}\n";
}