<?php
 declare(strict_types=1); namespace SpomkyLabs\Pki\X509\Certificate\Extension\PolicyMappings; use SpomkyLabs\Pki\ASN1\Type\Constructed\Sequence; use SpomkyLabs\Pki\ASN1\Type\Primitive\ObjectIdentifier; final class PolicyMapping { private function __construct( private readonly string $issuerDomainPolicy, private readonly string $subjectDomainPolicy ) { } public static function create(string $issuerDomainPolicy, string $subjectDomainPolicy): self { return new self($issuerDomainPolicy, $subjectDomainPolicy); } public static function fromASN1(Sequence $seq): self { $issuer_policy = $seq->at(0) ->asObjectIdentifier() ->oid(); $subject_policy = $seq->at(1) ->asObjectIdentifier() ->oid(); return self::create($issuer_policy, $subject_policy); } public function issuerDomainPolicy(): string { return $this->issuerDomainPolicy; } public function subjectDomainPolicy(): string { return $this->subjectDomainPolicy; } public function toASN1(): Sequence { return Sequence::create( ObjectIdentifier::create($this->issuerDomainPolicy), ObjectIdentifier::create($this->subjectDomainPolicy) ); } } 