Yoast\WP\SEO\MyYoast_Client\Domain

Discovery_Document::__constructpublicYoast 1.0

Discovery_Document constructor.

Validates that all OIDC-spec-required fields are present and that the server advertises support for all features this client depends on.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$Discovery_Document = new Discovery_Document();
$Discovery_Document->__construct( $data );
$data(массив) (обязательный)
.

Код Discovery_Document::__construct() Yoast 28.3

public function __construct( array $data ) {
	$spec_invalid = [];
	foreach ( self::SPEC_REQUIRED_STRING_FIELDS as $key ) {
		if ( ! isset( $data[ $key ] ) || ! \is_string( $data[ $key ] ) || $data[ $key ] === '' ) {
			$spec_invalid[] = $key;
		}
	}
	foreach ( self::SPEC_REQUIRED_ARRAY_FIELDS as $key ) {
		if ( ! isset( $data[ $key ] ) || ! self::is_non_empty_string_array( $data[ $key ] ) ) {
			$spec_invalid[] = $key;
		}
	}

	if ( ! empty( $spec_invalid ) ) {
		throw new Discovery_Failed_Exception(
			// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Internal exception message.
			\sprintf( 'OIDC discovery document has missing or invalid spec-required fields: %s', \implode( ', ', $spec_invalid ) ),
		);
	}

	$client_invalid = [];
	foreach ( self::CLIENT_REQUIRED_STRING_FIELDS as $key ) {
		if ( ! isset( $data[ $key ] ) || ! \is_string( $data[ $key ] ) || $data[ $key ] === '' ) {
			$client_invalid[] = $key;
		}
	}

	if ( ! empty( $client_invalid ) ) {
		throw new Server_Capability_Exception(
			// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Internal exception message.
			\sprintf( 'Server does not provide endpoints required by this client: %s', \implode( ', ', $client_invalid ) ),
		);
	}

	self::validate_server_capabilities( $data );

	$this->data = $data;
}