nullOr()->choice( AuthenticatorAttachment::ALL, 'authenticatorAttachment "%s" is not an element of the valid values: %s' ); Assert::that( $residentKey )->choice( ResidentKeyRequirement::ALL, 'residentKey "%s" is not an element of the valid values: %s' ); Assert::that( $userVerification )->choice( UserVerificationRequirement::ALL, 'userVerification "%s" is not an element of the valid values: %s' ); $this->authenticatorAttachment = $authenticatorAttachment; $this->residentKey = $residentKey; $this->userVerification = $userVerification; if ( $residentKey === ResidentKeyRequirement::REQUIRED ) { $this->requireResidentKey = true; } } public static function hydrate( array $data ): self { Assert::that( $data, 'AuthenticatorSelectionCredential hydration does not contain "%s".' ) ->keyExists( 'residentKey' ) ->keyExists( 'userVerification' ); return new self( $data['authenticatorAttachment'] ?? null, $data['residentKey'], $data['userVerification'] ); } public function get_authenticator_attachment(): string { return $this->authenticatorAttachment; } public function get_resident_key(): string { return $this->residentKey; } public function get_user_verification(): string { return $this->userVerification; } public function jsonSerialize(): array { $data = [ 'residentKey' => $this->residentKey, 'requireResidentKey' => $this->requireResidentKey, 'userVerification' => $this->userVerification, ]; if ( $this->authenticatorAttachment ) { $data['authenticatorAttachment'] = $this->authenticatorAttachment; } return $data; } }