Debian Codegraph @

lib/3rdParty/composer/spomky-labs/pki-framework/src/X509/Certificate/Extension/InhibitAnyPolicyExtension.php

raw symbols SCIP
1 <?php
2
3 declare(strict_types=1);
4
5 namespace SpomkyLabs\Pki\X509\Certificate\Extension;
6
7 use SpomkyLabs\Pki\ASN1\Element;
8 use SpomkyLabs\Pki\ASN1\Type\Primitive\Integer;
9 use SpomkyLabs\Pki\ASN1\Type\UnspecifiedType;
10
11 /**
12 * Implements 'Inhibit anyPolicy' extension.
13 *
14 * @see https://tools.ietf.org/html/rfc5280#section-4.2.1.14
15 */
16 final class InhibitAnyPolicyExtension extends Extension
17 {
18 private function __construct(
19 bool $critical,
20 private readonly int $skipCerts
21 ) {
22 parent::__construct(self::OID_INHIBIT_ANY_POLICY, $critical);
23 }
24
25 public static function create(bool $critical, int $skipCerts): self
26 {
27 return new self($critical, $skipCerts);
28 }
29
30 public function skipCerts(): int
31 {
32 return $this->skipCerts;
33 }
34
35 protected static function fromDER(string $data, bool $critical): static
36 {
37 return self::create($critical, UnspecifiedType::fromDER($data)->asInteger()->intNumber());
38 }
39
40 protected function valueASN1(): Element
41 {
42 return Integer::create($this->skipCerts);
43 }
44 }