| @@ 110-116 (lines=7) @@ | ||
| 107 | * @throws \UnexpectedValueException |
|
| 108 | * @return Boolean |
|
| 109 | */ |
|
| 110 | public function asBoolean() { |
|
| 111 | if (!$this->_element instanceof Boolean) { |
|
| 112 | throw new \UnexpectedValueException( |
|
| 113 | $this->_generateExceptionMessage(Element::TYPE_BOOLEAN)); |
|
| 114 | } |
|
| 115 | return $this->_element; |
|
| 116 | } |
|
| 117 | ||
| 118 | /** |
|
| 119 | * Get the wrapped element as an integer type. |
|
| @@ 124-130 (lines=7) @@ | ||
| 121 | * @throws \UnexpectedValueException |
|
| 122 | * @return Integer |
|
| 123 | */ |
|
| 124 | public function asInteger() { |
|
| 125 | if (!$this->_element instanceof Integer) { |
|
| 126 | throw new \UnexpectedValueException( |
|
| 127 | $this->_generateExceptionMessage(Element::TYPE_INTEGER)); |
|
| 128 | } |
|
| 129 | return $this->_element; |
|
| 130 | } |
|
| 131 | ||
| 132 | /** |
|
| 133 | * Get the wrapped element as a bit string type. |
|
| @@ 138-144 (lines=7) @@ | ||
| 135 | * @throws \UnexpectedValueException |
|
| 136 | * @return BitString |
|
| 137 | */ |
|
| 138 | public function asBitString() { |
|
| 139 | if (!$this->_element instanceof BitString) { |
|
| 140 | throw new \UnexpectedValueException( |
|
| 141 | $this->_generateExceptionMessage(Element::TYPE_BIT_STRING)); |
|
| 142 | } |
|
| 143 | return $this->_element; |
|
| 144 | } |
|
| 145 | ||
| 146 | /** |
|
| 147 | * Get the wrapped element as an octet string type. |
|
| @@ 152-158 (lines=7) @@ | ||
| 149 | * @throws \UnexpectedValueException |
|
| 150 | * @return OctetString |
|
| 151 | */ |
|
| 152 | public function asOctetString() { |
|
| 153 | if (!$this->_element instanceof OctetString) { |
|
| 154 | throw new \UnexpectedValueException( |
|
| 155 | $this->_generateExceptionMessage(Element::TYPE_OCTET_STRING)); |
|
| 156 | } |
|
| 157 | return $this->_element; |
|
| 158 | } |
|
| 159 | ||
| 160 | /** |
|
| 161 | * Get the wrapped element as a null type. |
|
| @@ 166-172 (lines=7) @@ | ||
| 163 | * @throws \UnexpectedValueException |
|
| 164 | * @return NullType |
|
| 165 | */ |
|
| 166 | public function asNull() { |
|
| 167 | if (!$this->_element instanceof NullType) { |
|
| 168 | throw new \UnexpectedValueException( |
|
| 169 | $this->_generateExceptionMessage(Element::TYPE_NULL)); |
|
| 170 | } |
|
| 171 | return $this->_element; |
|
| 172 | } |
|
| 173 | ||
| 174 | /** |
|
| 175 | * Get the wrapped element as an object identifier type. |
|
| @@ 180-187 (lines=8) @@ | ||
| 177 | * @throws \UnexpectedValueException |
|
| 178 | * @return ObjectIdentifier |
|
| 179 | */ |
|
| 180 | public function asObjectIdentifier() { |
|
| 181 | if (!$this->_element instanceof ObjectIdentifier) { |
|
| 182 | throw new \UnexpectedValueException( |
|
| 183 | $this->_generateExceptionMessage( |
|
| 184 | Element::TYPE_OBJECT_IDENTIFIER)); |
|
| 185 | } |
|
| 186 | return $this->_element; |
|
| 187 | } |
|
| 188 | ||
| 189 | /** |
|
| 190 | * Get the wrapped element as an object descriptor type. |
|
| @@ 195-202 (lines=8) @@ | ||
| 192 | * @throws \UnexpectedValueException |
|
| 193 | * @return ObjectDescriptor |
|
| 194 | */ |
|
| 195 | public function asObjectDescriptor() { |
|
| 196 | if (!$this->_element instanceof ObjectDescriptor) { |
|
| 197 | throw new \UnexpectedValueException( |
|
| 198 | $this->_generateExceptionMessage( |
|
| 199 | Element::TYPE_OBJECT_DESCRIPTOR)); |
|
| 200 | } |
|
| 201 | return $this->_element; |
|
| 202 | } |
|
| 203 | ||
| 204 | /** |
|
| 205 | * Get the wrapped element as a real type. |
|
| @@ 210-216 (lines=7) @@ | ||
| 207 | * @throws \UnexpectedValueException |
|
| 208 | * @return Real |
|
| 209 | */ |
|
| 210 | public function asReal() { |
|
| 211 | if (!$this->_element instanceof Real) { |
|
| 212 | throw new \UnexpectedValueException( |
|
| 213 | $this->_generateExceptionMessage(Element::TYPE_REAL)); |
|
| 214 | } |
|
| 215 | return $this->_element; |
|
| 216 | } |
|
| 217 | ||
| 218 | /** |
|
| 219 | * Get the wrapped element as an enumerated type. |
|
| @@ 224-230 (lines=7) @@ | ||
| 221 | * @throws \UnexpectedValueException |
|
| 222 | * @return Enumerated |
|
| 223 | */ |
|
| 224 | public function asEnumerated() { |
|
| 225 | if (!$this->_element instanceof Enumerated) { |
|
| 226 | throw new \UnexpectedValueException( |
|
| 227 | $this->_generateExceptionMessage(Element::TYPE_ENUMERATED)); |
|
| 228 | } |
|
| 229 | return $this->_element; |
|
| 230 | } |
|
| 231 | ||
| 232 | /** |
|
| 233 | * Get the wrapped element as a UTF8 string type. |
|
| @@ 238-244 (lines=7) @@ | ||
| 235 | * @throws \UnexpectedValueException |
|
| 236 | * @return UTF8String |
|
| 237 | */ |
|
| 238 | public function asUTF8String() { |
|
| 239 | if (!$this->_element instanceof UTF8String) { |
|
| 240 | throw new \UnexpectedValueException( |
|
| 241 | $this->_generateExceptionMessage(Element::TYPE_UTF8_STRING)); |
|
| 242 | } |
|
| 243 | return $this->_element; |
|
| 244 | } |
|
| 245 | ||
| 246 | /** |
|
| 247 | * Get the wrapped element as a relative OID type. |
|
| @@ 252-258 (lines=7) @@ | ||
| 249 | * @throws \UnexpectedValueException |
|
| 250 | * @return RelativeOID |
|
| 251 | */ |
|
| 252 | public function asRelativeOID() { |
|
| 253 | if (!$this->_element instanceof RelativeOID) { |
|
| 254 | throw new \UnexpectedValueException( |
|
| 255 | $this->_generateExceptionMessage(Element::TYPE_RELATIVE_OID)); |
|
| 256 | } |
|
| 257 | return $this->_element; |
|
| 258 | } |
|
| 259 | ||
| 260 | /** |
|
| 261 | * Get the wrapped element as a sequence type. |
|
| @@ 266-272 (lines=7) @@ | ||
| 263 | * @throws \UnexpectedValueException |
|
| 264 | * @return Sequence |
|
| 265 | */ |
|
| 266 | public function asSequence() { |
|
| 267 | if (!$this->_element instanceof Sequence) { |
|
| 268 | throw new \UnexpectedValueException( |
|
| 269 | $this->_generateExceptionMessage(Element::TYPE_SEQUENCE)); |
|
| 270 | } |
|
| 271 | return $this->_element; |
|
| 272 | } |
|
| 273 | ||
| 274 | /** |
|
| 275 | * Get the wrapped element as a set type. |
|
| @@ 280-286 (lines=7) @@ | ||
| 277 | * @throws \UnexpectedValueException |
|
| 278 | * @return Set |
|
| 279 | */ |
|
| 280 | public function asSet() { |
|
| 281 | if (!$this->_element instanceof Set) { |
|
| 282 | throw new \UnexpectedValueException( |
|
| 283 | $this->_generateExceptionMessage(Element::TYPE_SET)); |
|
| 284 | } |
|
| 285 | return $this->_element; |
|
| 286 | } |
|
| 287 | ||
| 288 | /** |
|
| 289 | * Get the wrapped element as a numeric string type. |
|
| @@ 294-300 (lines=7) @@ | ||
| 291 | * @throws \UnexpectedValueException |
|
| 292 | * @return NumericString |
|
| 293 | */ |
|
| 294 | public function asNumericString() { |
|
| 295 | if (!$this->_element instanceof NumericString) { |
|
| 296 | throw new \UnexpectedValueException( |
|
| 297 | $this->_generateExceptionMessage(Element::TYPE_NUMERIC_STRING)); |
|
| 298 | } |
|
| 299 | return $this->_element; |
|
| 300 | } |
|
| 301 | ||
| 302 | /** |
|
| 303 | * Get the wrapped element as a printable string type. |
|
| @@ 308-314 (lines=7) @@ | ||
| 305 | * @throws \UnexpectedValueException |
|
| 306 | * @return PrintableString |
|
| 307 | */ |
|
| 308 | public function asPrintableString() { |
|
| 309 | if (!$this->_element instanceof PrintableString) { |
|
| 310 | throw new \UnexpectedValueException( |
|
| 311 | $this->_generateExceptionMessage(Element::TYPE_PRINTABLE_STRING)); |
|
| 312 | } |
|
| 313 | return $this->_element; |
|
| 314 | } |
|
| 315 | ||
| 316 | /** |
|
| 317 | * Get the wrapped element as a T61 string type. |
|
| @@ 322-328 (lines=7) @@ | ||
| 319 | * @throws \UnexpectedValueException |
|
| 320 | * @return T61String |
|
| 321 | */ |
|
| 322 | public function asT61String() { |
|
| 323 | if (!$this->_element instanceof T61String) { |
|
| 324 | throw new \UnexpectedValueException( |
|
| 325 | $this->_generateExceptionMessage(Element::TYPE_T61_STRING)); |
|
| 326 | } |
|
| 327 | return $this->_element; |
|
| 328 | } |
|
| 329 | ||
| 330 | /** |
|
| 331 | * Get the wrapped element as a videotex string type. |
|
| @@ 336-342 (lines=7) @@ | ||
| 333 | * @throws \UnexpectedValueException |
|
| 334 | * @return VideotexString |
|
| 335 | */ |
|
| 336 | public function asVideotexString() { |
|
| 337 | if (!$this->_element instanceof VideotexString) { |
|
| 338 | throw new \UnexpectedValueException( |
|
| 339 | $this->_generateExceptionMessage(Element::TYPE_VIDEOTEX_STRING)); |
|
| 340 | } |
|
| 341 | return $this->_element; |
|
| 342 | } |
|
| 343 | ||
| 344 | /** |
|
| 345 | * Get the wrapped element as a IA6 string type. |
|
| @@ 350-356 (lines=7) @@ | ||
| 347 | * @throws \UnexpectedValueException |
|
| 348 | * @return IA5String |
|
| 349 | */ |
|
| 350 | public function asIA5String() { |
|
| 351 | if (!$this->_element instanceof IA5String) { |
|
| 352 | throw new \UnexpectedValueException( |
|
| 353 | $this->_generateExceptionMessage(Element::TYPE_IA5_STRING)); |
|
| 354 | } |
|
| 355 | return $this->_element; |
|
| 356 | } |
|
| 357 | ||
| 358 | /** |
|
| 359 | * Get the wrapped element as an UTC time type. |
|
| @@ 364-370 (lines=7) @@ | ||
| 361 | * @throws \UnexpectedValueException |
|
| 362 | * @return UTCTime |
|
| 363 | */ |
|
| 364 | public function asUTCTime() { |
|
| 365 | if (!$this->_element instanceof UTCTime) { |
|
| 366 | throw new \UnexpectedValueException( |
|
| 367 | $this->_generateExceptionMessage(Element::TYPE_UTC_TIME)); |
|
| 368 | } |
|
| 369 | return $this->_element; |
|
| 370 | } |
|
| 371 | ||
| 372 | /** |
|
| 373 | * Get the wrapped element as a generalized time type. |
|
| @@ 378-384 (lines=7) @@ | ||
| 375 | * @throws \UnexpectedValueException |
|
| 376 | * @return GeneralizedTime |
|
| 377 | */ |
|
| 378 | public function asGeneralizedTime() { |
|
| 379 | if (!$this->_element instanceof GeneralizedTime) { |
|
| 380 | throw new \UnexpectedValueException( |
|
| 381 | $this->_generateExceptionMessage(Element::TYPE_GENERALIZED_TIME)); |
|
| 382 | } |
|
| 383 | return $this->_element; |
|
| 384 | } |
|
| 385 | ||
| 386 | /** |
|
| 387 | * Get the wrapped element as a graphic string type. |
|
| @@ 392-398 (lines=7) @@ | ||
| 389 | * @throws \UnexpectedValueException |
|
| 390 | * @return GraphicString |
|
| 391 | */ |
|
| 392 | public function asGraphicString() { |
|
| 393 | if (!$this->_element instanceof GraphicString) { |
|
| 394 | throw new \UnexpectedValueException( |
|
| 395 | $this->_generateExceptionMessage(Element::TYPE_GRAPHIC_STRING)); |
|
| 396 | } |
|
| 397 | return $this->_element; |
|
| 398 | } |
|
| 399 | ||
| 400 | /** |
|
| 401 | * Get the wrapped element as a visible string type. |
|
| @@ 406-412 (lines=7) @@ | ||
| 403 | * @throws \UnexpectedValueException |
|
| 404 | * @return VisibleString |
|
| 405 | */ |
|
| 406 | public function asVisibleString() { |
|
| 407 | if (!$this->_element instanceof VisibleString) { |
|
| 408 | throw new \UnexpectedValueException( |
|
| 409 | $this->_generateExceptionMessage(Element::TYPE_VISIBLE_STRING)); |
|
| 410 | } |
|
| 411 | return $this->_element; |
|
| 412 | } |
|
| 413 | ||
| 414 | /** |
|
| 415 | * Get the wrapped element as a general string type. |
|
| @@ 420-426 (lines=7) @@ | ||
| 417 | * @throws \UnexpectedValueException |
|
| 418 | * @return GeneralString |
|
| 419 | */ |
|
| 420 | public function asGeneralString() { |
|
| 421 | if (!$this->_element instanceof GeneralString) { |
|
| 422 | throw new \UnexpectedValueException( |
|
| 423 | $this->_generateExceptionMessage(Element::TYPE_GENERAL_STRING)); |
|
| 424 | } |
|
| 425 | return $this->_element; |
|
| 426 | } |
|
| 427 | ||
| 428 | /** |
|
| 429 | * Get the wrapped element as a universal string type. |
|
| @@ 434-440 (lines=7) @@ | ||
| 431 | * @throws \UnexpectedValueException |
|
| 432 | * @return UniversalString |
|
| 433 | */ |
|
| 434 | public function asUniversalString() { |
|
| 435 | if (!$this->_element instanceof UniversalString) { |
|
| 436 | throw new \UnexpectedValueException( |
|
| 437 | $this->_generateExceptionMessage(Element::TYPE_UNIVERSAL_STRING)); |
|
| 438 | } |
|
| 439 | return $this->_element; |
|
| 440 | } |
|
| 441 | ||
| 442 | /** |
|
| 443 | * Get the wrapped element as a character string type. |
|
| @@ 448-454 (lines=7) @@ | ||
| 445 | * @throws \UnexpectedValueException |
|
| 446 | * @return CharacterString |
|
| 447 | */ |
|
| 448 | public function asCharacterString() { |
|
| 449 | if (!$this->_element instanceof CharacterString) { |
|
| 450 | throw new \UnexpectedValueException( |
|
| 451 | $this->_generateExceptionMessage(Element::TYPE_CHARACTER_STRING)); |
|
| 452 | } |
|
| 453 | return $this->_element; |
|
| 454 | } |
|
| 455 | ||
| 456 | /** |
|
| 457 | * Get the wrapped element as a BMP string type. |
|
| @@ 462-468 (lines=7) @@ | ||
| 459 | * @throws \UnexpectedValueException |
|
| 460 | * @return BMPString |
|
| 461 | */ |
|
| 462 | public function asBMPString() { |
|
| 463 | if (!$this->_element instanceof BMPString) { |
|
| 464 | throw new \UnexpectedValueException( |
|
| 465 | $this->_generateExceptionMessage(Element::TYPE_BMP_STRING)); |
|
| 466 | } |
|
| 467 | return $this->_element; |
|
| 468 | } |
|
| 469 | ||
| 470 | /** |
|
| 471 | * Get the wrapped element as any string type. |
|
| @@ 476-482 (lines=7) @@ | ||
| 473 | * @throws \UnexpectedValueException |
|
| 474 | * @return StringType |
|
| 475 | */ |
|
| 476 | public function asString() { |
|
| 477 | if (!$this->_element instanceof StringType) { |
|
| 478 | throw new \UnexpectedValueException( |
|
| 479 | $this->_generateExceptionMessage(Element::TYPE_STRING)); |
|
| 480 | } |
|
| 481 | return $this->_element; |
|
| 482 | } |
|
| 483 | ||
| 484 | /** |
|
| 485 | * Get the wrapped element as any time type. |
|
| @@ 490-496 (lines=7) @@ | ||
| 487 | * @throws \UnexpectedValueException |
|
| 488 | * @return TimeType |
|
| 489 | */ |
|
| 490 | public function asTime() { |
|
| 491 | if (!$this->_element instanceof TimeType) { |
|
| 492 | throw new \UnexpectedValueException( |
|
| 493 | $this->_generateExceptionMessage(Element::TYPE_TIME)); |
|
| 494 | } |
|
| 495 | return $this->_element; |
|
| 496 | } |
|
| 497 | ||
| 498 | /** |
|
| 499 | * Generate message for exceptions thrown by <code>as*</code> methods. |
|