addType('name', 'string'); $this->addType('uid', 'string'); $this->addType('publicKeyCredentialId', 'string'); $this->addType('data', 'string'); $this->addType('userVerification', 'boolean'); } public static function fromPublicKeyCrendentialSource(string $name, PublicKeyCredentialSource $publicKeyCredentialSource, bool $userVerification): PublicKeyCredentialEntity { $publicKeyCredentialEntity = new self(); $publicKeyCredentialEntity->setName($name); $publicKeyCredentialEntity->setUid($publicKeyCredentialSource->getUserHandle()); $publicKeyCredentialEntity->setPublicKeyCredentialId(base64_encode($publicKeyCredentialSource->getPublicKeyCredentialId())); $publicKeyCredentialEntity->setData(json_encode($publicKeyCredentialSource)); $publicKeyCredentialEntity->setUserVerification($userVerification); return $publicKeyCredentialEntity; } public function toPublicKeyCredentialSource(): PublicKeyCredentialSource { return PublicKeyCredentialSource::createFromArray( json_decode($this->getData(), true) ); } /** * @inheritDoc */ public function jsonSerialize(): array { return [ 'id' => $this->getId(), 'name' => $this->getName(), ]; } }