| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace SpomkyLabs\Pki\X501\ASN1\AttributeValue\Feature; |
| 6 |
|
| 7 |
use SpomkyLabs\Pki\ASN1\Element; |
| 8 |
use SpomkyLabs\Pki\ASN1\Type\Primitive\PrintableString; |
| 9 |
use SpomkyLabs\Pki\X501\ASN1\AttributeValue\AttributeValue; |
| 10 |
use SpomkyLabs\Pki\X501\DN\DNParser; |
| 11 |
use SpomkyLabs\Pki\X501\MatchingRule\CaseIgnoreMatch; |
| 12 |
use SpomkyLabs\Pki\X501\MatchingRule\MatchingRule; |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
abstract class PrintableStringValue extends AttributeValue |
| 18 |
{ |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
protected function __construct( |
| 23 |
string $oid, |
| 24 |
protected string $_string |
| 25 |
) { |
| 26 |
parent::__construct($oid); |
| 27 |
} |
| 28 |
|
| 29 |
public function toASN1(): Element |
| 30 |
{ |
| 31 |
return PrintableString::create($this->_string); |
| 32 |
} |
| 33 |
|
| 34 |
public function stringValue(): string |
| 35 |
{ |
| 36 |
return $this->_string; |
| 37 |
} |
| 38 |
|
| 39 |
public function equalityMatchingRule(): MatchingRule |
| 40 |
{ |
| 41 |
|
| 42 |
return CaseIgnoreMatch::create(Element::TYPE_PRINTABLE_STRING); |
| 43 |
} |
| 44 |
|
| 45 |
public function rfc2253String(): string |
| 46 |
{ |
| 47 |
return DNParser::escapeString($this->_transcodedString()); |
| 48 |
} |
| 49 |
|
| 50 |
protected function _transcodedString(): string |
| 51 |
{ |
| 52 |
|
| 53 |
return $this->_string; |
| 54 |
} |
| 55 |
} |