<?php

declare(strict_types=1);

namespace PhpWA\Auth;

use InvalidArgumentException;

final class PairingCodeRequest
{
      private $code;
      private $expiresAt;
    public function __construct(string $code, int $expiresAt)
    {
        if (preg_match('/\A[123456789ABCDEFGHJKLMNPQRSTVWXYZ]{4}-[123456789ABCDEFGHJKLMNPQRSTVWXYZ]{4}\z/D', $code) !== 1 || $expiresAt < 0) {
            throw new InvalidArgumentException('Pairing-code request result is invalid.');
        }
        $this->code = $code; $this->expiresAt = $expiresAt;
    }
    public function code(): string { return $this->code; }
    public function expiresAt(): int { return $this->expiresAt; }
}
