1 | <?php |
||
17 | */ |
||
18 | abstract class AccessDescription |
||
19 | { |
||
20 | /** |
||
21 | * Access method OID. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $_accessMethod; |
||
26 | |||
27 | /** |
||
28 | * Access location. |
||
29 | * |
||
30 | * @var GeneralName |
||
31 | */ |
||
32 | protected $_accessLocation; |
||
33 | |||
34 | /** |
||
35 | * Constructor. |
||
36 | * |
||
37 | * @param string $method Access method OID |
||
38 | * @param GeneralName $location Access location |
||
39 | */ |
||
40 | 16 | public function __construct(string $method, GeneralName $location) |
|
41 | { |
||
42 | 16 | $this->_accessMethod = $method; |
|
43 | 16 | $this->_accessLocation = $location; |
|
44 | 16 | } |
|
45 | |||
46 | /** |
||
47 | * Initialize from ASN.1. |
||
48 | * |
||
49 | * @param Sequence $seq |
||
50 | * |
||
51 | * @return self |
||
52 | */ |
||
53 | 12 | public static function fromASN1(Sequence $seq): self |
|
54 | { |
||
55 | 12 | return new static($seq->at(0)->asObjectIdentifier()->oid(), |
|
56 | 12 | GeneralName::fromASN1($seq->at(1)->asTagged())); |
|
57 | } |
||
58 | |||
59 | /** |
||
60 | * Get the access method OID. |
||
61 | * |
||
62 | * @return string |
||
63 | */ |
||
64 | 2 | public function accessMethod(): string |
|
65 | { |
||
66 | 2 | return $this->_accessMethod; |
|
67 | } |
||
68 | |||
69 | /** |
||
70 | * Get the access location. |
||
71 | * |
||
72 | * @return GeneralName |
||
73 | */ |
||
74 | 2 | public function accessLocation(): GeneralName |
|
75 | { |
||
76 | 2 | return $this->_accessLocation; |
|
77 | } |
||
78 | |||
79 | /** |
||
80 | * Generate ASN.1 structure. |
||
81 | * |
||
82 | * @return Sequence |
||
83 | */ |
||
84 | 18 | public function toASN1(): Sequence |
|
88 | } |
||
89 | } |
||
90 |