@@ -12,12 +12,12 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | interface PrepareStep |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * Apply string preparation step. |
|
| 17 | - * |
|
| 18 | - * @param string $string String to prepare |
|
| 19 | - * |
|
| 20 | - * @return string Prepared string |
|
| 21 | - */ |
|
| 22 | - public function apply(string $string): string; |
|
| 15 | + /** |
|
| 16 | + * Apply string preparation step. |
|
| 17 | + * |
|
| 18 | + * @param string $string String to prepare |
|
| 19 | + * |
|
| 20 | + * @return string Prepared string |
|
| 21 | + */ |
|
| 22 | + public function apply(string $string): string; |
|
| 23 | 23 | } |
@@ -12,13 +12,13 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class NormalizeStep implements PrepareStep |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * @param string $string UTF-8 encoded string |
|
| 17 | - * |
|
| 18 | - * @return string |
|
| 19 | - */ |
|
| 20 | - public function apply(string $string): string |
|
| 21 | - { |
|
| 22 | - return normalizer_normalize($string, \Normalizer::NFKC); |
|
| 23 | - } |
|
| 15 | + /** |
|
| 16 | + * @param string $string UTF-8 encoded string |
|
| 17 | + * |
|
| 18 | + * @return string |
|
| 19 | + */ |
|
| 20 | + public function apply(string $string): string |
|
| 21 | + { |
|
| 22 | + return normalizer_normalize($string, \Normalizer::NFKC); |
|
| 23 | + } |
|
| 24 | 24 | } |
@@ -15,52 +15,52 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class TranscodeStep implements PrepareStep |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * ASN.1 type of the string. |
|
| 20 | - * |
|
| 21 | - * @var int |
|
| 22 | - */ |
|
| 23 | - protected $_type; |
|
| 18 | + /** |
|
| 19 | + * ASN.1 type of the string. |
|
| 20 | + * |
|
| 21 | + * @var int |
|
| 22 | + */ |
|
| 23 | + protected $_type; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Constructor. |
|
| 27 | - * |
|
| 28 | - * @param int $type ASN.1 type tag of the string |
|
| 29 | - */ |
|
| 30 | - public function __construct(int $type) |
|
| 31 | - { |
|
| 32 | - $this->_type = $type; |
|
| 33 | - } |
|
| 25 | + /** |
|
| 26 | + * Constructor. |
|
| 27 | + * |
|
| 28 | + * @param int $type ASN.1 type tag of the string |
|
| 29 | + */ |
|
| 30 | + public function __construct(int $type) |
|
| 31 | + { |
|
| 32 | + $this->_type = $type; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @param string $string String to prepare |
|
| 37 | - * |
|
| 38 | - * @throws \LogicException If string type is not supported |
|
| 39 | - * |
|
| 40 | - * @return string UTF-8 encoded string |
|
| 41 | - */ |
|
| 42 | - public function apply(string $string): string |
|
| 43 | - { |
|
| 44 | - switch ($this->_type) { |
|
| 45 | - // UTF-8 string as is |
|
| 46 | - case Element::TYPE_UTF8_STRING: |
|
| 47 | - return $string; |
|
| 48 | - // PrintableString maps directly to UTF-8 |
|
| 49 | - case Element::TYPE_PRINTABLE_STRING: |
|
| 50 | - return $string; |
|
| 51 | - // UCS-2 to UTF-8 |
|
| 52 | - case Element::TYPE_BMP_STRING: |
|
| 53 | - return mb_convert_encoding($string, 'UTF-8', 'UCS-2BE'); |
|
| 54 | - // UCS-4 to UTF-8 |
|
| 55 | - case Element::TYPE_UNIVERSAL_STRING: |
|
| 56 | - return mb_convert_encoding($string, 'UTF-8', 'UCS-4BE'); |
|
| 57 | - // TeletexString mapping is a local matter. |
|
| 58 | - // We take a shortcut here and encode it as a hexstring. |
|
| 59 | - case Element::TYPE_T61_STRING: |
|
| 60 | - $el = new T61String($string); |
|
| 61 | - return '#' . bin2hex($el->toDER()); |
|
| 62 | - } |
|
| 63 | - throw new \LogicException( |
|
| 64 | - 'Unsupported string type ' . Element::tagToName($this->_type) . '.'); |
|
| 65 | - } |
|
| 35 | + /** |
|
| 36 | + * @param string $string String to prepare |
|
| 37 | + * |
|
| 38 | + * @throws \LogicException If string type is not supported |
|
| 39 | + * |
|
| 40 | + * @return string UTF-8 encoded string |
|
| 41 | + */ |
|
| 42 | + public function apply(string $string): string |
|
| 43 | + { |
|
| 44 | + switch ($this->_type) { |
|
| 45 | + // UTF-8 string as is |
|
| 46 | + case Element::TYPE_UTF8_STRING: |
|
| 47 | + return $string; |
|
| 48 | + // PrintableString maps directly to UTF-8 |
|
| 49 | + case Element::TYPE_PRINTABLE_STRING: |
|
| 50 | + return $string; |
|
| 51 | + // UCS-2 to UTF-8 |
|
| 52 | + case Element::TYPE_BMP_STRING: |
|
| 53 | + return mb_convert_encoding($string, 'UTF-8', 'UCS-2BE'); |
|
| 54 | + // UCS-4 to UTF-8 |
|
| 55 | + case Element::TYPE_UNIVERSAL_STRING: |
|
| 56 | + return mb_convert_encoding($string, 'UTF-8', 'UCS-4BE'); |
|
| 57 | + // TeletexString mapping is a local matter. |
|
| 58 | + // We take a shortcut here and encode it as a hexstring. |
|
| 59 | + case Element::TYPE_T61_STRING: |
|
| 60 | + $el = new T61String($string); |
|
| 61 | + return '#' . bin2hex($el->toDER()); |
|
| 62 | + } |
|
| 63 | + throw new \LogicException( |
|
| 64 | + 'Unsupported string type ' . Element::tagToName($this->_type) . '.'); |
|
| 65 | + } |
|
| 66 | 66 | } |
@@ -12,34 +12,34 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class MapStep implements PrepareStep |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * Whether to apply case folding. |
|
| 17 | - * |
|
| 18 | - * @var bool |
|
| 19 | - */ |
|
| 20 | - protected $_fold; |
|
| 15 | + /** |
|
| 16 | + * Whether to apply case folding. |
|
| 17 | + * |
|
| 18 | + * @var bool |
|
| 19 | + */ |
|
| 20 | + protected $_fold; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Constructor. |
|
| 24 | - * |
|
| 25 | - * @param bool $fold_case Whether to apply case folding |
|
| 26 | - */ |
|
| 27 | - public function __construct(bool $fold_case = false) |
|
| 28 | - { |
|
| 29 | - $this->_fold = $fold_case; |
|
| 30 | - } |
|
| 22 | + /** |
|
| 23 | + * Constructor. |
|
| 24 | + * |
|
| 25 | + * @param bool $fold_case Whether to apply case folding |
|
| 26 | + */ |
|
| 27 | + public function __construct(bool $fold_case = false) |
|
| 28 | + { |
|
| 29 | + $this->_fold = $fold_case; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @param string $string UTF-8 encoded string |
|
| 34 | - * |
|
| 35 | - * @return string |
|
| 36 | - */ |
|
| 37 | - public function apply(string $string): string |
|
| 38 | - { |
|
| 39 | - // @todo Implement character mappings |
|
| 40 | - if ($this->_fold) { |
|
| 41 | - $string = mb_convert_case($string, MB_CASE_LOWER, 'UTF-8'); |
|
| 42 | - } |
|
| 43 | - return $string; |
|
| 44 | - } |
|
| 32 | + /** |
|
| 33 | + * @param string $string UTF-8 encoded string |
|
| 34 | + * |
|
| 35 | + * @return string |
|
| 36 | + */ |
|
| 37 | + public function apply(string $string): string |
|
| 38 | + { |
|
| 39 | + // @todo Implement character mappings |
|
| 40 | + if ($this->_fold) { |
|
| 41 | + $string = mb_convert_case($string, MB_CASE_LOWER, 'UTF-8'); |
|
| 42 | + } |
|
| 43 | + return $string; |
|
| 44 | + } |
|
| 45 | 45 | } |
@@ -12,16 +12,16 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class ProhibitStep implements PrepareStep |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * @param string $string UTF-8 encoded string |
|
| 17 | - * |
|
| 18 | - * @throws \UnexpectedValueException If string contains prohibited characters |
|
| 19 | - * |
|
| 20 | - * @return string |
|
| 21 | - */ |
|
| 22 | - public function apply(string $string): string |
|
| 23 | - { |
|
| 24 | - // @todo Implement |
|
| 25 | - return $string; |
|
| 26 | - } |
|
| 15 | + /** |
|
| 16 | + * @param string $string UTF-8 encoded string |
|
| 17 | + * |
|
| 18 | + * @throws \UnexpectedValueException If string contains prohibited characters |
|
| 19 | + * |
|
| 20 | + * @return string |
|
| 21 | + */ |
|
| 22 | + public function apply(string $string): string |
|
| 23 | + { |
|
| 24 | + // @todo Implement |
|
| 25 | + return $string; |
|
| 26 | + } |
|
| 27 | 27 | } |
@@ -11,77 +11,77 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class StringPreparer |
| 13 | 13 | { |
| 14 | - const STEP_TRANSCODE = 1; |
|
| 15 | - const STEP_MAP = 2; |
|
| 16 | - const STEP_NORMALIZE = 3; |
|
| 17 | - const STEP_PROHIBIT = 4; |
|
| 18 | - const STEP_CHECK_BIDI = 5; |
|
| 19 | - const STEP_INSIGNIFICANT_CHARS = 6; |
|
| 14 | + const STEP_TRANSCODE = 1; |
|
| 15 | + const STEP_MAP = 2; |
|
| 16 | + const STEP_NORMALIZE = 3; |
|
| 17 | + const STEP_PROHIBIT = 4; |
|
| 18 | + const STEP_CHECK_BIDI = 5; |
|
| 19 | + const STEP_INSIGNIFICANT_CHARS = 6; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Preparation steps. |
|
| 23 | - * |
|
| 24 | - * @var PrepareStep[] |
|
| 25 | - */ |
|
| 26 | - protected $_steps; |
|
| 21 | + /** |
|
| 22 | + * Preparation steps. |
|
| 23 | + * |
|
| 24 | + * @var PrepareStep[] |
|
| 25 | + */ |
|
| 26 | + protected $_steps; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Constructor. |
|
| 30 | - * |
|
| 31 | - * @param PrepareStep[] $steps Preparation steps to apply |
|
| 32 | - */ |
|
| 33 | - protected function __construct(array $steps) |
|
| 34 | - { |
|
| 35 | - $this->_steps = $steps; |
|
| 36 | - } |
|
| 28 | + /** |
|
| 29 | + * Constructor. |
|
| 30 | + * |
|
| 31 | + * @param PrepareStep[] $steps Preparation steps to apply |
|
| 32 | + */ |
|
| 33 | + protected function __construct(array $steps) |
|
| 34 | + { |
|
| 35 | + $this->_steps = $steps; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Get default instance for given string type. |
|
| 40 | - * |
|
| 41 | - * @param int $string_type ASN.1 string type tag. |
|
| 42 | - * |
|
| 43 | - * @return self |
|
| 44 | - */ |
|
| 45 | - public static function forStringType(int $string_type): self |
|
| 46 | - { |
|
| 47 | - $steps = [ |
|
| 48 | - self::STEP_TRANSCODE => new TranscodeStep($string_type), |
|
| 49 | - self::STEP_MAP => new MapStep(), |
|
| 50 | - self::STEP_NORMALIZE => new NormalizeStep(), |
|
| 51 | - self::STEP_PROHIBIT => new ProhibitStep(), |
|
| 52 | - self::STEP_CHECK_BIDI => new CheckBidiStep(), |
|
| 53 | - // @todo Vary by string type |
|
| 54 | - self::STEP_INSIGNIFICANT_CHARS => new InsignificantNonSubstringSpaceStep(), |
|
| 55 | - ]; |
|
| 56 | - return new self($steps); |
|
| 57 | - } |
|
| 38 | + /** |
|
| 39 | + * Get default instance for given string type. |
|
| 40 | + * |
|
| 41 | + * @param int $string_type ASN.1 string type tag. |
|
| 42 | + * |
|
| 43 | + * @return self |
|
| 44 | + */ |
|
| 45 | + public static function forStringType(int $string_type): self |
|
| 46 | + { |
|
| 47 | + $steps = [ |
|
| 48 | + self::STEP_TRANSCODE => new TranscodeStep($string_type), |
|
| 49 | + self::STEP_MAP => new MapStep(), |
|
| 50 | + self::STEP_NORMALIZE => new NormalizeStep(), |
|
| 51 | + self::STEP_PROHIBIT => new ProhibitStep(), |
|
| 52 | + self::STEP_CHECK_BIDI => new CheckBidiStep(), |
|
| 53 | + // @todo Vary by string type |
|
| 54 | + self::STEP_INSIGNIFICANT_CHARS => new InsignificantNonSubstringSpaceStep(), |
|
| 55 | + ]; |
|
| 56 | + return new self($steps); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Get self with case folding set. |
|
| 61 | - * |
|
| 62 | - * @param bool $fold True to apply case folding |
|
| 63 | - * |
|
| 64 | - * @return self |
|
| 65 | - */ |
|
| 66 | - public function withCaseFolding(bool $fold): self |
|
| 67 | - { |
|
| 68 | - $obj = clone $this; |
|
| 69 | - $obj->_steps[self::STEP_MAP] = new MapStep($fold); |
|
| 70 | - return $obj; |
|
| 71 | - } |
|
| 59 | + /** |
|
| 60 | + * Get self with case folding set. |
|
| 61 | + * |
|
| 62 | + * @param bool $fold True to apply case folding |
|
| 63 | + * |
|
| 64 | + * @return self |
|
| 65 | + */ |
|
| 66 | + public function withCaseFolding(bool $fold): self |
|
| 67 | + { |
|
| 68 | + $obj = clone $this; |
|
| 69 | + $obj->_steps[self::STEP_MAP] = new MapStep($fold); |
|
| 70 | + return $obj; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Prepare string. |
|
| 75 | - * |
|
| 76 | - * @param string $string |
|
| 77 | - * |
|
| 78 | - * @return string |
|
| 79 | - */ |
|
| 80 | - public function prepare(string $string): string |
|
| 81 | - { |
|
| 82 | - foreach ($this->_steps as $step) { |
|
| 83 | - $string = $step->apply($string); |
|
| 84 | - } |
|
| 85 | - return $string; |
|
| 86 | - } |
|
| 73 | + /** |
|
| 74 | + * Prepare string. |
|
| 75 | + * |
|
| 76 | + * @param string $string |
|
| 77 | + * |
|
| 78 | + * @return string |
|
| 79 | + */ |
|
| 80 | + public function prepare(string $string): string |
|
| 81 | + { |
|
| 82 | + foreach ($this->_steps as $step) { |
|
| 83 | + $string = $step->apply($string); |
|
| 84 | + } |
|
| 85 | + return $string; |
|
| 86 | + } |
|
| 87 | 87 | } |
@@ -12,14 +12,14 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class CheckBidiStep implements PrepareStep |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * @param string $string UTF-8 encoded string |
|
| 17 | - * |
|
| 18 | - * @return string |
|
| 19 | - */ |
|
| 20 | - public function apply(string $string): string |
|
| 21 | - { |
|
| 22 | - // @todo Implement |
|
| 23 | - return $string; |
|
| 24 | - } |
|
| 15 | + /** |
|
| 16 | + * @param string $string UTF-8 encoded string |
|
| 17 | + * |
|
| 18 | + * @return string |
|
| 19 | + */ |
|
| 20 | + public function apply(string $string): string |
|
| 21 | + { |
|
| 22 | + // @todo Implement |
|
| 23 | + return $string; |
|
| 24 | + } |
|
| 25 | 25 | } |
@@ -14,22 +14,22 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class InsignificantNonSubstringSpaceStep implements PrepareStep |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * @param string $string UTF-8 encoded string |
|
| 19 | - * |
|
| 20 | - * @return string |
|
| 21 | - */ |
|
| 22 | - public function apply(string $string): string |
|
| 23 | - { |
|
| 24 | - // if value contains no non-space characters |
|
| 25 | - if (preg_match('/^\p{Zs}*$/u', $string)) { |
|
| 26 | - return ' '; |
|
| 27 | - } |
|
| 28 | - // trim leading and trailing spaces |
|
| 29 | - $string = preg_replace('/^\p{Zs}+/u', '', $string); |
|
| 30 | - $string = preg_replace('/\p{Zs}+$/u', '', $string); |
|
| 31 | - // convert inner space sequences to two U+0020 characters |
|
| 32 | - $string = preg_replace('/\p{Zs}+/u', ' ', $string); |
|
| 33 | - return " {$string} "; |
|
| 34 | - } |
|
| 17 | + /** |
|
| 18 | + * @param string $string UTF-8 encoded string |
|
| 19 | + * |
|
| 20 | + * @return string |
|
| 21 | + */ |
|
| 22 | + public function apply(string $string): string |
|
| 23 | + { |
|
| 24 | + // if value contains no non-space characters |
|
| 25 | + if (preg_match('/^\p{Zs}*$/u', $string)) { |
|
| 26 | + return ' '; |
|
| 27 | + } |
|
| 28 | + // trim leading and trailing spaces |
|
| 29 | + $string = preg_replace('/^\p{Zs}+/u', '', $string); |
|
| 30 | + $string = preg_replace('/\p{Zs}+$/u', '', $string); |
|
| 31 | + // convert inner space sequences to two U+0020 characters |
|
| 32 | + $string = preg_replace('/\p{Zs}+/u', ' ', $string); |
|
| 33 | + return " {$string} "; |
|
| 34 | + } |
|
| 35 | 35 | } |
@@ -15,114 +15,114 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class AttributeTypeAndValue |
| 17 | 17 | { |
| 18 | - use TypedAttribute; |
|
| 18 | + use TypedAttribute; |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Attribute value. |
|
| 22 | - * |
|
| 23 | - * @var AttributeValue |
|
| 24 | - */ |
|
| 25 | - protected $_value; |
|
| 20 | + /** |
|
| 21 | + * Attribute value. |
|
| 22 | + * |
|
| 23 | + * @var AttributeValue |
|
| 24 | + */ |
|
| 25 | + protected $_value; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Constructor. |
|
| 29 | - * |
|
| 30 | - * @param AttributeType $type Attribute type |
|
| 31 | - * @param AttributeValue $value Attribute value |
|
| 32 | - */ |
|
| 33 | - public function __construct(AttributeType $type, AttributeValue $value) |
|
| 34 | - { |
|
| 35 | - $this->_type = $type; |
|
| 36 | - $this->_value = $value; |
|
| 37 | - } |
|
| 27 | + /** |
|
| 28 | + * Constructor. |
|
| 29 | + * |
|
| 30 | + * @param AttributeType $type Attribute type |
|
| 31 | + * @param AttributeValue $value Attribute value |
|
| 32 | + */ |
|
| 33 | + public function __construct(AttributeType $type, AttributeValue $value) |
|
| 34 | + { |
|
| 35 | + $this->_type = $type; |
|
| 36 | + $this->_value = $value; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @return string |
|
| 41 | - */ |
|
| 42 | - public function __toString() |
|
| 43 | - { |
|
| 44 | - return $this->toString(); |
|
| 45 | - } |
|
| 39 | + /** |
|
| 40 | + * @return string |
|
| 41 | + */ |
|
| 42 | + public function __toString() |
|
| 43 | + { |
|
| 44 | + return $this->toString(); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Initialize from ASN.1. |
|
| 49 | - * |
|
| 50 | - * @param Sequence $seq |
|
| 51 | - * |
|
| 52 | - * @return self |
|
| 53 | - */ |
|
| 54 | - public static function fromASN1(Sequence $seq): self |
|
| 55 | - { |
|
| 56 | - $type = AttributeType::fromASN1($seq->at(0)->asObjectIdentifier()); |
|
| 57 | - $value = AttributeValue::fromASN1ByOID($type->oid(), $seq->at(1)); |
|
| 58 | - return new self($type, $value); |
|
| 59 | - } |
|
| 47 | + /** |
|
| 48 | + * Initialize from ASN.1. |
|
| 49 | + * |
|
| 50 | + * @param Sequence $seq |
|
| 51 | + * |
|
| 52 | + * @return self |
|
| 53 | + */ |
|
| 54 | + public static function fromASN1(Sequence $seq): self |
|
| 55 | + { |
|
| 56 | + $type = AttributeType::fromASN1($seq->at(0)->asObjectIdentifier()); |
|
| 57 | + $value = AttributeValue::fromASN1ByOID($type->oid(), $seq->at(1)); |
|
| 58 | + return new self($type, $value); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Convenience method to initialize from attribute value. |
|
| 63 | - * |
|
| 64 | - * @param AttributeValue $value Attribute value |
|
| 65 | - * |
|
| 66 | - * @return self |
|
| 67 | - */ |
|
| 68 | - public static function fromAttributeValue(AttributeValue $value): self |
|
| 69 | - { |
|
| 70 | - return new self(new AttributeType($value->oid()), $value); |
|
| 71 | - } |
|
| 61 | + /** |
|
| 62 | + * Convenience method to initialize from attribute value. |
|
| 63 | + * |
|
| 64 | + * @param AttributeValue $value Attribute value |
|
| 65 | + * |
|
| 66 | + * @return self |
|
| 67 | + */ |
|
| 68 | + public static function fromAttributeValue(AttributeValue $value): self |
|
| 69 | + { |
|
| 70 | + return new self(new AttributeType($value->oid()), $value); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Get attribute value. |
|
| 75 | - * |
|
| 76 | - * @return AttributeValue |
|
| 77 | - */ |
|
| 78 | - public function value(): AttributeValue |
|
| 79 | - { |
|
| 80 | - return $this->_value; |
|
| 81 | - } |
|
| 73 | + /** |
|
| 74 | + * Get attribute value. |
|
| 75 | + * |
|
| 76 | + * @return AttributeValue |
|
| 77 | + */ |
|
| 78 | + public function value(): AttributeValue |
|
| 79 | + { |
|
| 80 | + return $this->_value; |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * Generate ASN.1 structure. |
|
| 85 | - * |
|
| 86 | - * @return Sequence |
|
| 87 | - */ |
|
| 88 | - public function toASN1(): Sequence |
|
| 89 | - { |
|
| 90 | - return new Sequence($this->_type->toASN1(), $this->_value->toASN1()); |
|
| 91 | - } |
|
| 83 | + /** |
|
| 84 | + * Generate ASN.1 structure. |
|
| 85 | + * |
|
| 86 | + * @return Sequence |
|
| 87 | + */ |
|
| 88 | + public function toASN1(): Sequence |
|
| 89 | + { |
|
| 90 | + return new Sequence($this->_type->toASN1(), $this->_value->toASN1()); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * Get attributeTypeAndValue string conforming to RFC 2253. |
|
| 95 | - * |
|
| 96 | - * @see https://tools.ietf.org/html/rfc2253#section-2.3 |
|
| 97 | - * |
|
| 98 | - * @return string |
|
| 99 | - */ |
|
| 100 | - public function toString(): string |
|
| 101 | - { |
|
| 102 | - return $this->_type->typeName() . '=' . $this->_value->rfc2253String(); |
|
| 103 | - } |
|
| 93 | + /** |
|
| 94 | + * Get attributeTypeAndValue string conforming to RFC 2253. |
|
| 95 | + * |
|
| 96 | + * @see https://tools.ietf.org/html/rfc2253#section-2.3 |
|
| 97 | + * |
|
| 98 | + * @return string |
|
| 99 | + */ |
|
| 100 | + public function toString(): string |
|
| 101 | + { |
|
| 102 | + return $this->_type->typeName() . '=' . $this->_value->rfc2253String(); |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * Check whether attribute is semantically equal to other. |
|
| 107 | - * |
|
| 108 | - * @param AttributeTypeAndValue $other Object to compare to |
|
| 109 | - * |
|
| 110 | - * @return bool |
|
| 111 | - */ |
|
| 112 | - public function equals(AttributeTypeAndValue $other): bool |
|
| 113 | - { |
|
| 114 | - // check that attribute types match |
|
| 115 | - if ($this->oid() !== $other->oid()) { |
|
| 116 | - return false; |
|
| 117 | - } |
|
| 118 | - $matcher = $this->_value->equalityMatchingRule(); |
|
| 119 | - $result = $matcher->compare($this->_value->stringValue(), |
|
| 120 | - $other->_value->stringValue()); |
|
| 121 | - // match |
|
| 122 | - if ($result) { |
|
| 123 | - return true; |
|
| 124 | - } |
|
| 125 | - // no match or Undefined |
|
| 126 | - return false; |
|
| 127 | - } |
|
| 105 | + /** |
|
| 106 | + * Check whether attribute is semantically equal to other. |
|
| 107 | + * |
|
| 108 | + * @param AttributeTypeAndValue $other Object to compare to |
|
| 109 | + * |
|
| 110 | + * @return bool |
|
| 111 | + */ |
|
| 112 | + public function equals(AttributeTypeAndValue $other): bool |
|
| 113 | + { |
|
| 114 | + // check that attribute types match |
|
| 115 | + if ($this->oid() !== $other->oid()) { |
|
| 116 | + return false; |
|
| 117 | + } |
|
| 118 | + $matcher = $this->_value->equalityMatchingRule(); |
|
| 119 | + $result = $matcher->compare($this->_value->stringValue(), |
|
| 120 | + $other->_value->stringValue()); |
|
| 121 | + // match |
|
| 122 | + if ($result) { |
|
| 123 | + return true; |
|
| 124 | + } |
|
| 125 | + // no match or Undefined |
|
| 126 | + return false; |
|
| 127 | + } |
|
| 128 | 128 | } |