<?php
 declare(strict_types=1); namespace SpomkyLabs\Pki\X509\Certificate; use SpomkyLabs\Pki\ASN1\Type\Constructed\Sequence; final class Validity { private function __construct( private readonly Time $notBefore, private readonly Time $notAfter ) { } public static function create(Time $notBefore, Time $notAfter): self { return new self($notBefore, $notAfter); } public static function fromASN1(Sequence $seq): self { $nb = Time::fromASN1($seq->at(0)->asTime()); $na = Time::fromASN1($seq->at(1)->asTime()); return self::create($nb, $na); } public static function fromStrings(?string $nb_date, ?string $na_date, ?string $tz = null): self { return self::create(Time::fromString($nb_date, $tz), Time::fromString($na_date, $tz)); } public function notBefore(): Time { return $this->notBefore; } public function notAfter(): Time { return $this->notAfter; } public function toASN1(): Sequence { return Sequence::create($this->notBefore->toASN1(), $this->notAfter->toASN1()); } } 