1 | <?php |
||
18 | class IetfAttrValue |
||
19 | { |
||
20 | /** |
||
21 | * Element type tag. |
||
22 | * |
||
23 | * @var int $_type |
||
24 | */ |
||
25 | protected $_type; |
||
26 | |||
27 | /** |
||
28 | * Value. |
||
29 | * |
||
30 | * @var string $_value |
||
31 | */ |
||
32 | protected $_value; |
||
33 | |||
34 | /** |
||
35 | * Constructor. |
||
36 | * |
||
37 | * @param string $value |
||
38 | * @param int $type |
||
39 | */ |
||
40 | public function __construct(string $value, int $type) |
||
45 | |||
46 | /** |
||
47 | * Initialize from ASN.1. |
||
48 | * |
||
49 | * @param UnspecifiedType $el |
||
50 | * @throws \UnexpectedValueException |
||
51 | * @return self |
||
52 | */ |
||
53 | public static function fromASN1(UnspecifiedType $el) |
||
65 | |||
66 | /** |
||
67 | * Initialize from octet string. |
||
68 | * |
||
69 | * @param string $octets |
||
70 | * @return self |
||
71 | */ |
||
72 | public static function fromOctets(string $octets) |
||
76 | |||
77 | /** |
||
78 | * Initialize from UTF-8 string. |
||
79 | * |
||
80 | * @param string $str |
||
81 | * @return self |
||
82 | */ |
||
83 | public static function fromString(string $str) |
||
87 | |||
88 | /** |
||
89 | * Initialize from OID. |
||
90 | * |
||
91 | * @param string $oid |
||
92 | * @return self |
||
93 | */ |
||
94 | public static function fromOID(string $oid) |
||
98 | |||
99 | /** |
||
100 | * Get type tag. |
||
101 | * |
||
102 | * @return int |
||
103 | */ |
||
104 | public function type(): int |
||
108 | |||
109 | /** |
||
110 | * Whether value type is octets. |
||
111 | * |
||
112 | * @return bool |
||
113 | */ |
||
114 | public function isOctets(): bool |
||
118 | |||
119 | /** |
||
120 | * Whether value type is OID. |
||
121 | * |
||
122 | * @return bool |
||
123 | */ |
||
124 | public function isOID(): bool |
||
128 | |||
129 | /** |
||
130 | * Whether value type is string. |
||
131 | * |
||
132 | * @return bool |
||
133 | */ |
||
134 | public function isString(): bool |
||
138 | |||
139 | /** |
||
140 | * Get value. |
||
141 | * |
||
142 | * @return string |
||
143 | */ |
||
144 | public function value(): string |
||
148 | |||
149 | /** |
||
150 | * Generate ASN.1 structure. |
||
151 | * |
||
152 | * @throws \LogicException |
||
153 | * @return Element |
||
154 | */ |
||
155 | public function toASN1(): Element |
||
168 | |||
169 | /** |
||
170 | * |
||
171 | * @return string |
||
172 | */ |
||
173 | public function __toString() |
||
177 | } |
||
178 |