<?php declare(strict_types=1);

namespace App\Engine\Admin\Auth;

use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: WebauthnCredentialRepository::class)]
class WebauthnCredential extends \Webauthn\CredentialRecord
{

    #[ORM\Id]
    #[ORM\Column(unique: true)]
    #[ORM\GeneratedValue(strategy: "NONE")]
    private string $id;
    #[ORM\Column(type: "datetime")]
    private \DateTime $createdAt;

    public function __construct(
        string                        $publicKeyCredentialId,
        string                        $type,
        array                         $transports,
        string                        $attestationType,
        \Webauthn\TrustPath\TrustPath $trustPath,
        \Symfony\Component\Uid\Uuid   $aaguid,
        string                        $credentialPublicKey,
        string                        $userHandle,
        int                           $counter,
    ) {
        $this->id = \Symfony\Component\Uid\Ulid::generate();
        $this->createdAt = new \DateTime();
        parent::__construct($publicKeyCredentialId, $type, $transports, $attestationType, $trustPath, $aaguid, $credentialPublicKey, $userHandle, $counter);
    }

    public function getId(): string
    {
        return $this->id;
    }

    public function getCreatedAt(): \DateTime
    {
        return $this->createdAt;
    }

    public function setCreatedAt(\DateTime $createdAt): void
    {
        $this->createdAt = $createdAt;
    }


}