PrintableString.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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\Universal;
  11. use FG\ASN1\AbstractString;
  12. use FG\ASN1\Identifier;
  13. class PrintableString extends AbstractString
  14. {
  15. /**
  16. * Creates a new ASN.1 PrintableString.
  17. *
  18. * The ITU-T X.680 Table 8 permits the following characters:
  19. * Latin capital letters A,B, ... Z
  20. * Latin small letters a,b, ... z
  21. * Digits 0,1, ... 9
  22. * SPACE (space)
  23. * APOSTROPHE '
  24. * LEFT PARENTHESIS (
  25. * RIGHT PARENTHESIS )
  26. * PLUS SIGN +
  27. * COMMA ,
  28. * HYPHEN-MINUS -
  29. * FULL STOP .
  30. * SOLIDUS /
  31. * COLON :
  32. * EQUALS SIGN =
  33. * QUESTION MARK ?
  34. *
  35. * @param string $string
  36. */
  37. public function __construct($string)
  38. {
  39. $this->value = $string;
  40. $this->allowNumbers();
  41. $this->allowAllLetters();
  42. $this->allowSpaces();
  43. $this->allowCharacters("'", '(', ')', '+', '-', '.', ',', '/', ':', '=', '?');
  44. }
  45. public function getType()
  46. {
  47. return Identifier::PRINTABLE_STRING;
  48. }
  49. }