RDNString.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  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\Composite;
  11. use FG\ASN1\Universal\PrintableString;
  12. use FG\ASN1\Universal\IA5String;
  13. use FG\ASN1\Universal\UTF8String;
  14. class RDNString extends RelativeDistinguishedName
  15. {
  16. /**
  17. * @param string|\FG\ASN1\Universal\ObjectIdentifier $objectIdentifierString
  18. * @param string|\FG\ASN1\ASNObject $value
  19. */
  20. public function __construct($objectIdentifierString, $value)
  21. {
  22. if (PrintableString::isValid($value)) {
  23. $value = new PrintableString($value);
  24. } else {
  25. if (IA5String::isValid($value)) {
  26. $value = new IA5String($value);
  27. } else {
  28. $value = new UTF8String($value);
  29. }
  30. }
  31. parent::__construct($objectIdentifierString, $value);
  32. }
  33. }