Yoast\WP\SEO\Expiring_Store\Application

Expiring_Store::json_encode_valueprivateYoast 1.0

JSON-encodes a value.

Метод класса: Expiring_Store{}

Хуков нет.

Возвращает

Строку. The JSON-encoded value.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->json_encode_value( $value ): string;
$value(строка|int|float|true|false|array<string|int|float|true|false|массив|null>|JsonSerializable) (обязательный)
The value to encode.

Код Expiring_Store::json_encode_value() Yoast 27.7

private function json_encode_value( $value ): string {
	// phpcs:ignore Yoast.Yoast.JsonEncodeAlternative.Found -- WPSEO_Utils::format_json_encode we don't intend to output this.
	$encoded = \wp_json_encode( $value );

	if ( $encoded === false ) {
		// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- This is an exception message, not output.
		throw new InvalidArgumentException( 'Expiring_Store: value must be JSON-encodable. ' . \json_last_error_msg() );
	}

	return $encoded;
}