| Total Complexity | 5 |
| Total Lines | 63 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | abstract class DistributionPointName |
||
| 20 | { |
||
| 21 | const TAG_FULL_NAME = 0; |
||
| 22 | const TAG_RDN = 1; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Type. |
||
| 26 | * |
||
| 27 | * @var int |
||
| 28 | */ |
||
| 29 | protected $_tag; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Initialize from TaggedType. |
||
| 33 | * |
||
| 34 | * @param TaggedType $el |
||
| 35 | * |
||
| 36 | * @throws \UnexpectedValueException |
||
| 37 | * |
||
| 38 | * @return self |
||
| 39 | */ |
||
| 40 | 15 | public static function fromTaggedType(TaggedType $el): self |
|
| 41 | { |
||
| 42 | 15 | switch ($el->tag()) { |
|
| 43 | 15 | case self::TAG_FULL_NAME: |
|
| 44 | 12 | return new FullName( |
|
| 45 | 12 | GeneralNames::fromASN1( |
|
| 46 | 12 | $el->asImplicit(Element::TYPE_SEQUENCE)->asSequence())); |
|
| 47 | 11 | case self::TAG_RDN: |
|
| 48 | 10 | return new RelativeName( |
|
| 49 | 10 | RDN::fromASN1($el->asImplicit(Element::TYPE_SET)->asSet())); |
|
| 50 | default: |
||
| 51 | 1 | throw new \UnexpectedValueException( |
|
| 52 | 1 | 'DistributionPointName tag ' . $el->tag() . ' not supported.'); |
|
| 53 | } |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Get type tag. |
||
| 58 | * |
||
| 59 | * @return int |
||
| 60 | */ |
||
| 61 | 7 | public function tag(): int |
|
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Generate ASN.1 structure. |
||
| 68 | * |
||
| 69 | * @return ImplicitlyTaggedType |
||
| 70 | */ |
||
| 71 | 20 | public function toASN1(): ImplicitlyTaggedType |
|
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Generate ASN.1 element. |
||
| 78 | * |
||
| 79 | * @return Element |
||
| 80 | */ |
||
| 81 | abstract protected function _valueASN1(): Element; |
||
| 82 | } |
||
| 83 |