Yoast\WP\SEO\MyYoast_Client\Domain

Auth_Flow_State::from_array │ public static │ Yoast 1.0

Creates an Auth_Flow_State from a stored array.

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

Хуков нет.

Возвращает

self.

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

$result = Auth_Flow_State::from_array( $data ): self;
$data(array<string, string|null>) (обязательный)
The stored array data.

Код Auth_Flow_State::from_array() Yoast 28.9

public static function from_array( array $data ): self {
	$required = [ 'code_verifier', 'state', 'redirect_uri' ];
	foreach ( $required as $key ) {
		if ( ! isset( $data[ $key ] ) || ! \is_string( $data[ $key ] ) ) {
			// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Internal exception message.
			throw new InvalidArgumentException( "Auth_Flow_State::from_array() requires a string value for '{$key}'." );
		}
	}
	$optional_strings = [ 'nonce', 'return_url', 'resource_indicator' ];
	foreach ( $optional_strings as $key ) {
		if ( isset( $data[ $key ] ) && ! \is_string( $data[ $key ] ) ) {
			// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Internal exception message.
			throw new InvalidArgumentException( "Auth_Flow_State::from_array() requires '{$key}' to be a string or null." );
		}
	}

	$stored_indicator = ( $data['resource_indicator'] ?? null );

	return new self(
		$data['code_verifier'],
		$data['state'],
		( $data['nonce'] ?? null ),
		$data['redirect_uri'],
		( $data['return_url'] ?? null ),
		new Resource_Indicator( ( \is_string( $stored_indicator ) && $stored_indicator !== '' ) ? $stored_indicator : null ),
	);
}