| 1 | <?php |
||
| 14 | abstract class Target |
||
| 15 | { |
||
| 16 | const TYPE_NAME = 0; |
||
| 17 | const TYPE_GROUP = 1; |
||
| 18 | const TYPE_CERT = 2; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Type tag. |
||
| 22 | * |
||
| 23 | * @var int $_type |
||
| 24 | */ |
||
| 25 | protected $_type; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Generate ASN.1 element. |
||
| 29 | * |
||
| 30 | * @return \ASN1\Element |
||
| 31 | */ |
||
| 32 | abstract public function toASN1(); |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Get string value of the target. |
||
| 36 | * |
||
| 37 | * @return string |
||
| 38 | */ |
||
| 39 | abstract public function string(): string; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Initialize concrete object from the chosen ASN.1 element. |
||
| 43 | * |
||
| 44 | * @param TaggedType $el |
||
| 45 | * @return self |
||
| 46 | */ |
||
| 47 | 1 | public static function fromChosenASN1(TaggedType $el) |
|
| 52 | |||
| 53 | /** |
||
| 54 | * Parse from ASN.1. |
||
| 55 | * |
||
| 56 | * @param TaggedType $el |
||
| 57 | * @throws \UnexpectedValueException |
||
| 58 | * @return self |
||
| 59 | */ |
||
| 60 | 8 | public static function fromASN1(TaggedType $el): self |
|
| 74 | |||
| 75 | /** |
||
| 76 | * Get type tag. |
||
| 77 | * |
||
| 78 | * @return int |
||
| 79 | */ |
||
| 80 | 8 | public function type(): int |
|
| 84 | |||
| 85 | /** |
||
| 86 | * Check whether target is equal to another. |
||
| 87 | * |
||
| 88 | * @param Target $other |
||
| 89 | * @return bool |
||
| 90 | */ |
||
| 91 | 8 | public function equals(Target $other): bool |
|
| 101 | } |
||
| 102 |