|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace X501\ASN1\AttributeValue\Feature; |
|
4
|
|
|
|
|
5
|
|
|
use ASN1\Element; |
|
6
|
|
|
use ASN1\Feature\ElementBase; |
|
7
|
|
|
use ASN1\Type\Primitive\PrintableString; |
|
8
|
|
|
use ASN1\Type\UnspecifiedType; |
|
9
|
|
|
use X501\ASN1\AttributeValue\AttributeValue; |
|
10
|
|
|
use X501\DN\DNParser; |
|
11
|
|
|
use X501\MatchingRule\CaseIgnoreMatch; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Base class for attribute values having <i>PrintableString</i> syntax. |
|
16
|
|
|
*/ |
|
17
|
|
|
abstract class PrintableStringValue extends AttributeValue |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* String value. |
|
21
|
|
|
* |
|
22
|
|
|
* @var string $_string |
|
23
|
|
|
*/ |
|
24
|
|
|
protected $_string; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Constructor |
|
28
|
|
|
* |
|
29
|
|
|
* @param string $string String value |
|
|
|
|
|
|
30
|
|
|
*/ |
|
31
|
6 |
|
public function __construct($value) { |
|
32
|
6 |
|
$this->_string = $value; |
|
33
|
6 |
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* |
|
37
|
|
|
* @see AttributeValue::fromASN1 |
|
38
|
|
|
* @param ElementBase $el |
|
39
|
|
|
* @return self |
|
40
|
|
|
*/ |
|
41
|
4 |
|
public static function fromASN1(ElementBase $el) { |
|
42
|
4 |
|
$type = new UnspecifiedType($el->asElement()); |
|
43
|
4 |
|
return new static($type->asPrintableString()->string()); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* |
|
48
|
|
|
* @see AttributeValue::toASN1 |
|
49
|
|
|
* @return PrintableString |
|
50
|
|
|
*/ |
|
51
|
2 |
|
public function toASN1() { |
|
52
|
2 |
|
return new PrintableString($this->_string); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* |
|
57
|
|
|
* @see AttributeValue::stringValue |
|
58
|
|
|
* @return string |
|
59
|
|
|
*/ |
|
60
|
1 |
|
public function stringValue() { |
|
61
|
1 |
|
return $this->_string; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* |
|
66
|
|
|
* @see AttributeValue::equalityMatchingRule |
|
67
|
|
|
* @return CaseIgnoreMatch |
|
68
|
|
|
*/ |
|
69
|
1 |
|
public function equalityMatchingRule() { |
|
70
|
|
|
// default to caseIgnoreMatch |
|
71
|
1 |
|
return new CaseIgnoreMatch(Element::TYPE_PRINTABLE_STRING); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* |
|
76
|
|
|
* @see AttributeValue::rfc2253String |
|
77
|
|
|
* @return string |
|
78
|
|
|
*/ |
|
79
|
1 |
|
public function rfc2253String() { |
|
80
|
1 |
|
return DNParser::escapeString($this->_transcodedString()); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* |
|
85
|
|
|
* @see AttributeValue::_transcodedString |
|
86
|
|
|
* @return string |
|
87
|
|
|
*/ |
|
88
|
1 |
|
protected function _transcodedString() { |
|
89
|
|
|
// PrintableString maps directly to UTF-8 |
|
90
|
1 |
|
return $this->_string; |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.