UnknownObject.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /*
  3. * This file is part of the PHPASN1 library.
  4. *
  5. * Copyright © Friedrich Große <friedrich.grosse@gmail.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace FG\ASN1;
  11. class UnknownObject extends ASNObject
  12. {
  13. /** @var string */
  14. private $value;
  15. private $identifier;
  16. /**
  17. * @param string|int $identifier Either the first identifier octet as int or all identifier bytes as a string
  18. * @param int $contentLength
  19. */
  20. public function __construct($identifier, $contentLength)
  21. {
  22. if (is_int($identifier)) {
  23. $identifier = chr($identifier);
  24. }
  25. $this->identifier = $identifier;
  26. $this->value = "Unparsable Object ({$contentLength} bytes)";
  27. $this->setContentLength($contentLength);
  28. }
  29. public function getContent()
  30. {
  31. return $this->value;
  32. }
  33. public function getType()
  34. {
  35. return ord($this->identifier[0]);
  36. }
  37. public function getIdentifier()
  38. {
  39. return $this->identifier;
  40. }
  41. protected function calculateContentLength()
  42. {
  43. return $this->getContentLength();
  44. }
  45. protected function getEncodedValue()
  46. {
  47. return '';
  48. }
  49. }