<?php
 declare(strict_types=1); namespace SpomkyLabs\Pki\X509\Certificate\Extension\CertificatePolicy; use SpomkyLabs\Pki\ASN1\Type\Constructed\Sequence; use SpomkyLabs\Pki\ASN1\Type\Primitive\Integer; use SpomkyLabs\Pki\ASN1\Type\UnspecifiedType; final class NoticeReference { private readonly array $numbers; private function __construct( private readonly DisplayText $organization, int ...$numbers ) { $this->numbers = $numbers; } public static function create(DisplayText $organization, int ...$numbers): self { return new self($organization, ...$numbers); } public static function fromASN1(Sequence $seq): self { $org = DisplayText::fromASN1($seq->at(0)->asString()); $numbers = array_map( static fn (UnspecifiedType $el) => $el->asInteger() ->intNumber(), $seq->at(1) ->asSequence() ->elements() ); return self::create($org, ...$numbers); } public function organization(): DisplayText { return $this->organization; } public function numbers(): array { return $this->numbers; } public function toASN1(): Sequence { $org = $this->organization->toASN1(); $nums = array_map(Integer::create(...), $this->numbers); return Sequence::create($org, Sequence::create(...$nums)); } } 