Yoast\WP\SEO\Expiring_Store\Application

Expiring_Store::do_getprivateYoast 1.0

Gets and decodes a value by prefixed key.

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

Хуков нет.

Возвращает

Строку|int|float|true|false|Массив<Строку|int|float|true|false|Массив|null>. The stored value.

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

// private - только в коде основоного (родительского) класса
$result = $this->do_get( $prefixed_key );
$prefixed_key(строка) (обязательный)
The prefixed key.

Код Expiring_Store::do_get() Yoast 27.7

private function do_get( string $prefixed_key ) {
	$json = $this->repository->find( $prefixed_key, $this->current_datetime() );

	if ( $json === null ) {
		// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Internal exception message.
		throw new Key_Not_Found_Exception( "Key '{$prefixed_key}' not found or expired." );
	}

	try {
		return \json_decode( $json, true, 512, \JSON_THROW_ON_ERROR );
	} catch ( JsonException $e ) {
		// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- This is an exception message, not output.
		throw new Corrupted_Value_Exception( $prefixed_key, $e->getMessage() );
	}
}