Passed
Push — php72 ( a3eac9...46ea07 )
by Joni
02:06
created
lib/X501/ASN1/AttributeValue/OrganizationalUnitNameValue.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -14,16 +14,16 @@
 block discarded – undo
14 14
  */
15 15
 class OrganizationalUnitNameValue extends DirectoryString
16 16
 {
17
-    /**
18
-     * Constructor.
19
-     *
20
-     * @param string $value      String value
21
-     * @param int    $string_tag Syntax choice
22
-     */
23
-    public function __construct(string $value,
24
-        int $string_tag = DirectoryString::UTF8)
25
-    {
26
-        $this->_oid = AttributeType::OID_ORGANIZATIONAL_UNIT_NAME;
27
-        parent::__construct($value, $string_tag);
28
-    }
17
+	/**
18
+	 * Constructor.
19
+	 *
20
+	 * @param string $value      String value
21
+	 * @param int    $string_tag Syntax choice
22
+	 */
23
+	public function __construct(string $value,
24
+		int $string_tag = DirectoryString::UTF8)
25
+	{
26
+		$this->_oid = AttributeType::OID_ORGANIZATIONAL_UNIT_NAME;
27
+		parent::__construct($value, $string_tag);
28
+	}
29 29
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X501\ASN1\AttributeValue;
6 6
 
Please login to merge, or discard this patch.
lib/X501/ASN1/AttributeValue/AttributeValue.php 2 patches
Indentation   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -18,157 +18,157 @@
 block discarded – undo
18 18
  */
19 19
 abstract class AttributeValue
20 20
 {
21
-    /**
22
-     * Mapping from attribute type OID to attribute value class name.
23
-     *
24
-     * @internal
25
-     *
26
-     * @var array
27
-     */
28
-    const MAP_OID_TO_CLASS = [
29
-        AttributeType::OID_COMMON_NAME => CommonNameValue::class,
30
-        AttributeType::OID_SURNAME => SurnameValue::class,
31
-        AttributeType::OID_SERIAL_NUMBER => SerialNumberValue::class,
32
-        AttributeType::OID_COUNTRY_NAME => CountryNameValue::class,
33
-        AttributeType::OID_LOCALITY_NAME => LocalityNameValue::class,
34
-        AttributeType::OID_STATE_OR_PROVINCE_NAME => StateOrProvinceNameValue::class,
35
-        AttributeType::OID_ORGANIZATION_NAME => OrganizationNameValue::class,
36
-        AttributeType::OID_ORGANIZATIONAL_UNIT_NAME => OrganizationalUnitNameValue::class,
37
-        AttributeType::OID_TITLE => TitleValue::class,
38
-        AttributeType::OID_DESCRIPTION => DescriptionValue::class,
39
-        AttributeType::OID_NAME => NameValue::class,
40
-        AttributeType::OID_GIVEN_NAME => GivenNameValue::class,
41
-        AttributeType::OID_PSEUDONYM => PseudonymValue::class,
42
-    ];
43
-
44
-    /**
45
-     * OID of the attribute type.
46
-     *
47
-     * @var string
48
-     */
49
-    protected $_oid;
50
-
51
-    /**
52
-     * Get attribute value as an UTF-8 encoded string.
53
-     *
54
-     * @return string
55
-     */
56
-    public function __toString()
57
-    {
58
-        return $this->_transcodedString();
59
-    }
60
-
61
-    /**
62
-     * Generate ASN.1 element.
63
-     *
64
-     * @return Element
65
-     */
66
-    abstract public function toASN1(): Element;
67
-
68
-    /**
69
-     * Get attribute value as a string.
70
-     *
71
-     * @return string
72
-     */
73
-    abstract public function stringValue(): string;
74
-
75
-    /**
76
-     * Get matching rule for equality comparison.
77
-     *
78
-     * @return MatchingRule
79
-     */
80
-    abstract public function equalityMatchingRule(): MatchingRule;
81
-
82
-    /**
83
-     * Get attribute value as a string conforming to RFC 2253.
84
-     *
85
-     * @see https://tools.ietf.org/html/rfc2253#section-2.4
86
-     *
87
-     * @return string
88
-     */
89
-    abstract public function rfc2253String(): string;
90
-
91
-    /**
92
-     * Initialize from ASN.1.
93
-     *
94
-     * @param UnspecifiedType $el
95
-     *
96
-     * @return self
97
-     */
98
-    public static function fromASN1(UnspecifiedType $el): AttributeValue
99
-    {
100
-        throw new \BadMethodCallException(
101
-            'ASN.1 parsing must be implemented in a concrete class.');
102
-    }
103
-
104
-    /**
105
-     * Initialize from ASN.1 with given OID hint.
106
-     *
107
-     * @param string          $oid Attribute's OID
108
-     * @param UnspecifiedType $el
109
-     *
110
-     * @return self
111
-     */
112
-    public static function fromASN1ByOID(string $oid, UnspecifiedType $el): self
113
-    {
114
-        if (!array_key_exists($oid, self::MAP_OID_TO_CLASS)) {
115
-            return new UnknownAttributeValue($oid, $el->asElement());
116
-        }
117
-        $cls = self::MAP_OID_TO_CLASS[$oid];
118
-        return $cls::fromASN1($el);
119
-    }
120
-
121
-    /**
122
-     * Initialize from another AttributeValue.
123
-     *
124
-     * This method is generally used to cast UnknownAttributeValue to
125
-     * specific object when class is declared outside this package.
126
-     *
127
-     * @param self $obj Instance of AttributeValue
128
-     *
129
-     * @return self
130
-     */
131
-    public static function fromSelf(self $obj): self
132
-    {
133
-        return static::fromASN1($obj->toASN1()->asUnspecified());
134
-    }
135
-
136
-    /**
137
-     * Get attribute type's OID.
138
-     *
139
-     * @return string
140
-     */
141
-    public function oid(): string
142
-    {
143
-        return $this->_oid;
144
-    }
145
-
146
-    /**
147
-     * Get Attribute object with this as a single value.
148
-     *
149
-     * @return Attribute
150
-     */
151
-    public function toAttribute(): Attribute
152
-    {
153
-        return Attribute::fromAttributeValues($this);
154
-    }
155
-
156
-    /**
157
-     * Get AttributeTypeAndValue object with this as a value.
158
-     *
159
-     * @return AttributeTypeAndValue
160
-     */
161
-    public function toAttributeTypeAndValue(): AttributeTypeAndValue
162
-    {
163
-        return AttributeTypeAndValue::fromAttributeValue($this);
164
-    }
165
-
166
-    /**
167
-     * Get attribute value as an UTF-8 string conforming to RFC 4518.
168
-     *
169
-     * @see https://tools.ietf.org/html/rfc4518#section-2.1
170
-     *
171
-     * @return string
172
-     */
173
-    abstract protected function _transcodedString(): string;
21
+	/**
22
+	 * Mapping from attribute type OID to attribute value class name.
23
+	 *
24
+	 * @internal
25
+	 *
26
+	 * @var array
27
+	 */
28
+	const MAP_OID_TO_CLASS = [
29
+		AttributeType::OID_COMMON_NAME => CommonNameValue::class,
30
+		AttributeType::OID_SURNAME => SurnameValue::class,
31
+		AttributeType::OID_SERIAL_NUMBER => SerialNumberValue::class,
32
+		AttributeType::OID_COUNTRY_NAME => CountryNameValue::class,
33
+		AttributeType::OID_LOCALITY_NAME => LocalityNameValue::class,
34
+		AttributeType::OID_STATE_OR_PROVINCE_NAME => StateOrProvinceNameValue::class,
35
+		AttributeType::OID_ORGANIZATION_NAME => OrganizationNameValue::class,
36
+		AttributeType::OID_ORGANIZATIONAL_UNIT_NAME => OrganizationalUnitNameValue::class,
37
+		AttributeType::OID_TITLE => TitleValue::class,
38
+		AttributeType::OID_DESCRIPTION => DescriptionValue::class,
39
+		AttributeType::OID_NAME => NameValue::class,
40
+		AttributeType::OID_GIVEN_NAME => GivenNameValue::class,
41
+		AttributeType::OID_PSEUDONYM => PseudonymValue::class,
42
+	];
43
+
44
+	/**
45
+	 * OID of the attribute type.
46
+	 *
47
+	 * @var string
48
+	 */
49
+	protected $_oid;
50
+
51
+	/**
52
+	 * Get attribute value as an UTF-8 encoded string.
53
+	 *
54
+	 * @return string
55
+	 */
56
+	public function __toString()
57
+	{
58
+		return $this->_transcodedString();
59
+	}
60
+
61
+	/**
62
+	 * Generate ASN.1 element.
63
+	 *
64
+	 * @return Element
65
+	 */
66
+	abstract public function toASN1(): Element;
67
+
68
+	/**
69
+	 * Get attribute value as a string.
70
+	 *
71
+	 * @return string
72
+	 */
73
+	abstract public function stringValue(): string;
74
+
75
+	/**
76
+	 * Get matching rule for equality comparison.
77
+	 *
78
+	 * @return MatchingRule
79
+	 */
80
+	abstract public function equalityMatchingRule(): MatchingRule;
81
+
82
+	/**
83
+	 * Get attribute value as a string conforming to RFC 2253.
84
+	 *
85
+	 * @see https://tools.ietf.org/html/rfc2253#section-2.4
86
+	 *
87
+	 * @return string
88
+	 */
89
+	abstract public function rfc2253String(): string;
90
+
91
+	/**
92
+	 * Initialize from ASN.1.
93
+	 *
94
+	 * @param UnspecifiedType $el
95
+	 *
96
+	 * @return self
97
+	 */
98
+	public static function fromASN1(UnspecifiedType $el): AttributeValue
99
+	{
100
+		throw new \BadMethodCallException(
101
+			'ASN.1 parsing must be implemented in a concrete class.');
102
+	}
103
+
104
+	/**
105
+	 * Initialize from ASN.1 with given OID hint.
106
+	 *
107
+	 * @param string          $oid Attribute's OID
108
+	 * @param UnspecifiedType $el
109
+	 *
110
+	 * @return self
111
+	 */
112
+	public static function fromASN1ByOID(string $oid, UnspecifiedType $el): self
113
+	{
114
+		if (!array_key_exists($oid, self::MAP_OID_TO_CLASS)) {
115
+			return new UnknownAttributeValue($oid, $el->asElement());
116
+		}
117
+		$cls = self::MAP_OID_TO_CLASS[$oid];
118
+		return $cls::fromASN1($el);
119
+	}
120
+
121
+	/**
122
+	 * Initialize from another AttributeValue.
123
+	 *
124
+	 * This method is generally used to cast UnknownAttributeValue to
125
+	 * specific object when class is declared outside this package.
126
+	 *
127
+	 * @param self $obj Instance of AttributeValue
128
+	 *
129
+	 * @return self
130
+	 */
131
+	public static function fromSelf(self $obj): self
132
+	{
133
+		return static::fromASN1($obj->toASN1()->asUnspecified());
134
+	}
135
+
136
+	/**
137
+	 * Get attribute type's OID.
138
+	 *
139
+	 * @return string
140
+	 */
141
+	public function oid(): string
142
+	{
143
+		return $this->_oid;
144
+	}
145
+
146
+	/**
147
+	 * Get Attribute object with this as a single value.
148
+	 *
149
+	 * @return Attribute
150
+	 */
151
+	public function toAttribute(): Attribute
152
+	{
153
+		return Attribute::fromAttributeValues($this);
154
+	}
155
+
156
+	/**
157
+	 * Get AttributeTypeAndValue object with this as a value.
158
+	 *
159
+	 * @return AttributeTypeAndValue
160
+	 */
161
+	public function toAttributeTypeAndValue(): AttributeTypeAndValue
162
+	{
163
+		return AttributeTypeAndValue::fromAttributeValue($this);
164
+	}
165
+
166
+	/**
167
+	 * Get attribute value as an UTF-8 string conforming to RFC 4518.
168
+	 *
169
+	 * @see https://tools.ietf.org/html/rfc4518#section-2.1
170
+	 *
171
+	 * @return string
172
+	 */
173
+	abstract protected function _transcodedString(): string;
174 174
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X501\ASN1\AttributeValue;
6 6
 
Please login to merge, or discard this patch.
lib/X501/ASN1/AttributeValue/CommonNameValue.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -14,16 +14,16 @@
 block discarded – undo
14 14
  */
15 15
 class CommonNameValue extends DirectoryString
16 16
 {
17
-    /**
18
-     * Constructor.
19
-     *
20
-     * @param string $value      String value
21
-     * @param int    $string_tag Syntax choice
22
-     */
23
-    public function __construct(string $value,
24
-        int $string_tag = DirectoryString::UTF8)
25
-    {
26
-        $this->_oid = AttributeType::OID_COMMON_NAME;
27
-        parent::__construct($value, $string_tag);
28
-    }
17
+	/**
18
+	 * Constructor.
19
+	 *
20
+	 * @param string $value      String value
21
+	 * @param int    $string_tag Syntax choice
22
+	 */
23
+	public function __construct(string $value,
24
+		int $string_tag = DirectoryString::UTF8)
25
+	{
26
+		$this->_oid = AttributeType::OID_COMMON_NAME;
27
+		parent::__construct($value, $string_tag);
28
+	}
29 29
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X501\ASN1\AttributeValue;
6 6
 
Please login to merge, or discard this patch.
lib/X501/ASN1/AttributeValue/TitleValue.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -14,16 +14,16 @@
 block discarded – undo
14 14
  */
15 15
 class TitleValue extends DirectoryString
16 16
 {
17
-    /**
18
-     * Constructor.
19
-     *
20
-     * @param string $value      String value
21
-     * @param int    $string_tag Syntax choice
22
-     */
23
-    public function __construct(string $value,
24
-        int $string_tag = DirectoryString::UTF8)
25
-    {
26
-        $this->_oid = AttributeType::OID_TITLE;
27
-        parent::__construct($value, $string_tag);
28
-    }
17
+	/**
18
+	 * Constructor.
19
+	 *
20
+	 * @param string $value      String value
21
+	 * @param int    $string_tag Syntax choice
22
+	 */
23
+	public function __construct(string $value,
24
+		int $string_tag = DirectoryString::UTF8)
25
+	{
26
+		$this->_oid = AttributeType::OID_TITLE;
27
+		parent::__construct($value, $string_tag);
28
+	}
29 29
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X501\ASN1\AttributeValue;
6 6
 
Please login to merge, or discard this patch.
lib/X501/ASN1/AttributeValue/Feature/DirectoryString.php 2 patches
Indentation   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -25,156 +25,156 @@
 block discarded – undo
25 25
  */
26 26
 abstract class DirectoryString extends AttributeValue
27 27
 {
28
-    /**
29
-     * Teletex string syntax.
30
-     *
31
-     * @var int
32
-     */
33
-    const TELETEX = Element::TYPE_T61_STRING;
34
-
35
-    /**
36
-     * Printable string syntax.
37
-     *
38
-     * @var int
39
-     */
40
-    const PRINTABLE = Element::TYPE_PRINTABLE_STRING;
41
-
42
-    /**
43
-     * BMP string syntax.
44
-     *
45
-     * @var int
46
-     */
47
-    const BMP = Element::TYPE_BMP_STRING;
48
-
49
-    /**
50
-     * Universal string syntax.
51
-     *
52
-     * @var int
53
-     */
54
-    const UNIVERSAL = Element::TYPE_UNIVERSAL_STRING;
55
-
56
-    /**
57
-     * UTF-8 string syntax.
58
-     *
59
-     * @var int
60
-     */
61
-    const UTF8 = Element::TYPE_UTF8_STRING;
62
-
63
-    /**
64
-     * Mapping from syntax enumeration to ASN.1 class name.
65
-     *
66
-     * @internal
67
-     *
68
-     * @var array
69
-     */
70
-    const MAP_TAG_TO_CLASS = [
71
-        self::TELETEX => T61String::class,
72
-        self::PRINTABLE => PrintableString::class,
73
-        self::UNIVERSAL => UniversalString::class,
74
-        self::UTF8 => UTF8String::class,
75
-        self::BMP => BMPString::class,
76
-    ];
77
-
78
-    /**
79
-     * ASN.1 type tag for the chosen syntax.
80
-     *
81
-     * @var int
82
-     */
83
-    protected $_stringTag;
84
-
85
-    /**
86
-     * String value.
87
-     *
88
-     * @var string
89
-     */
90
-    protected $_string;
91
-
92
-    /**
93
-     * Constructor.
94
-     *
95
-     * @param string $value      String value
96
-     * @param int    $string_tag Syntax choice
97
-     */
98
-    public function __construct(string $value, int $string_tag)
99
-    {
100
-        $this->_string = $value;
101
-        $this->_stringTag = $string_tag;
102
-    }
103
-
104
-    /**
105
-     * {@inheritdoc}
106
-     *
107
-     * @return self
108
-     */
109
-    public static function fromASN1(UnspecifiedType $el): AttributeValue
110
-    {
111
-        $tag = $el->tag();
112
-        self::_tagToASN1Class($tag);
113
-        return new static($el->asString()->string(), $tag);
114
-    }
115
-
116
-    /**
117
-     * {@inheritdoc}
118
-     */
119
-    public function toASN1(): Element
120
-    {
121
-        $cls = self::_tagToASN1Class($this->_stringTag);
122
-        return new $cls($this->_string);
123
-    }
124
-
125
-    /**
126
-     * {@inheritdoc}
127
-     */
128
-    public function stringValue(): string
129
-    {
130
-        return $this->_string;
131
-    }
132
-
133
-    /**
134
-     * {@inheritdoc}
135
-     */
136
-    public function equalityMatchingRule(): MatchingRule
137
-    {
138
-        return new CaseIgnoreMatch($this->_stringTag);
139
-    }
140
-
141
-    /**
142
-     * {@inheritdoc}
143
-     */
144
-    public function rfc2253String(): string
145
-    {
146
-        // TeletexString is encoded as binary
147
-        if (self::TELETEX == $this->_stringTag) {
148
-            return $this->_transcodedString();
149
-        }
150
-        return DNParser::escapeString($this->_transcodedString());
151
-    }
152
-
153
-    /**
154
-     * {@inheritdoc}
155
-     */
156
-    protected function _transcodedString(): string
157
-    {
158
-        $step = new TranscodeStep($this->_stringTag);
159
-        return $step->apply($this->_string);
160
-    }
161
-
162
-    /**
163
-     * Get ASN.1 class name for given DirectoryString type tag.
164
-     *
165
-     * @param int $tag
166
-     *
167
-     * @throws \UnexpectedValueException
168
-     *
169
-     * @return string
170
-     */
171
-    private static function _tagToASN1Class(int $tag): string
172
-    {
173
-        if (!array_key_exists($tag, self::MAP_TAG_TO_CLASS)) {
174
-            throw new \UnexpectedValueException(
175
-                'Type ' . Element::tagToName($tag) .
176
-                     ' is not valid DirectoryString.');
177
-        }
178
-        return self::MAP_TAG_TO_CLASS[$tag];
179
-    }
28
+	/**
29
+	 * Teletex string syntax.
30
+	 *
31
+	 * @var int
32
+	 */
33
+	const TELETEX = Element::TYPE_T61_STRING;
34
+
35
+	/**
36
+	 * Printable string syntax.
37
+	 *
38
+	 * @var int
39
+	 */
40
+	const PRINTABLE = Element::TYPE_PRINTABLE_STRING;
41
+
42
+	/**
43
+	 * BMP string syntax.
44
+	 *
45
+	 * @var int
46
+	 */
47
+	const BMP = Element::TYPE_BMP_STRING;
48
+
49
+	/**
50
+	 * Universal string syntax.
51
+	 *
52
+	 * @var int
53
+	 */
54
+	const UNIVERSAL = Element::TYPE_UNIVERSAL_STRING;
55
+
56
+	/**
57
+	 * UTF-8 string syntax.
58
+	 *
59
+	 * @var int
60
+	 */
61
+	const UTF8 = Element::TYPE_UTF8_STRING;
62
+
63
+	/**
64
+	 * Mapping from syntax enumeration to ASN.1 class name.
65
+	 *
66
+	 * @internal
67
+	 *
68
+	 * @var array
69
+	 */
70
+	const MAP_TAG_TO_CLASS = [
71
+		self::TELETEX => T61String::class,
72
+		self::PRINTABLE => PrintableString::class,
73
+		self::UNIVERSAL => UniversalString::class,
74
+		self::UTF8 => UTF8String::class,
75
+		self::BMP => BMPString::class,
76
+	];
77
+
78
+	/**
79
+	 * ASN.1 type tag for the chosen syntax.
80
+	 *
81
+	 * @var int
82
+	 */
83
+	protected $_stringTag;
84
+
85
+	/**
86
+	 * String value.
87
+	 *
88
+	 * @var string
89
+	 */
90
+	protected $_string;
91
+
92
+	/**
93
+	 * Constructor.
94
+	 *
95
+	 * @param string $value      String value
96
+	 * @param int    $string_tag Syntax choice
97
+	 */
98
+	public function __construct(string $value, int $string_tag)
99
+	{
100
+		$this->_string = $value;
101
+		$this->_stringTag = $string_tag;
102
+	}
103
+
104
+	/**
105
+	 * {@inheritdoc}
106
+	 *
107
+	 * @return self
108
+	 */
109
+	public static function fromASN1(UnspecifiedType $el): AttributeValue
110
+	{
111
+		$tag = $el->tag();
112
+		self::_tagToASN1Class($tag);
113
+		return new static($el->asString()->string(), $tag);
114
+	}
115
+
116
+	/**
117
+	 * {@inheritdoc}
118
+	 */
119
+	public function toASN1(): Element
120
+	{
121
+		$cls = self::_tagToASN1Class($this->_stringTag);
122
+		return new $cls($this->_string);
123
+	}
124
+
125
+	/**
126
+	 * {@inheritdoc}
127
+	 */
128
+	public function stringValue(): string
129
+	{
130
+		return $this->_string;
131
+	}
132
+
133
+	/**
134
+	 * {@inheritdoc}
135
+	 */
136
+	public function equalityMatchingRule(): MatchingRule
137
+	{
138
+		return new CaseIgnoreMatch($this->_stringTag);
139
+	}
140
+
141
+	/**
142
+	 * {@inheritdoc}
143
+	 */
144
+	public function rfc2253String(): string
145
+	{
146
+		// TeletexString is encoded as binary
147
+		if (self::TELETEX == $this->_stringTag) {
148
+			return $this->_transcodedString();
149
+		}
150
+		return DNParser::escapeString($this->_transcodedString());
151
+	}
152
+
153
+	/**
154
+	 * {@inheritdoc}
155
+	 */
156
+	protected function _transcodedString(): string
157
+	{
158
+		$step = new TranscodeStep($this->_stringTag);
159
+		return $step->apply($this->_string);
160
+	}
161
+
162
+	/**
163
+	 * Get ASN.1 class name for given DirectoryString type tag.
164
+	 *
165
+	 * @param int $tag
166
+	 *
167
+	 * @throws \UnexpectedValueException
168
+	 *
169
+	 * @return string
170
+	 */
171
+	private static function _tagToASN1Class(int $tag): string
172
+	{
173
+		if (!array_key_exists($tag, self::MAP_TAG_TO_CLASS)) {
174
+			throw new \UnexpectedValueException(
175
+				'Type ' . Element::tagToName($tag) .
176
+					 ' is not valid DirectoryString.');
177
+		}
178
+		return self::MAP_TAG_TO_CLASS[$tag];
179
+	}
180 180
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X501\ASN1\AttributeValue\Feature;
6 6
 
Please login to merge, or discard this patch.
lib/X501/ASN1/AttributeValue/Feature/PrintableStringValue.php 2 patches
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -17,72 +17,72 @@
 block discarded – undo
17 17
  */
18 18
 abstract class PrintableStringValue extends AttributeValue
19 19
 {
20
-    /**
21
-     * String value.
22
-     *
23
-     * @var string
24
-     */
25
-    protected $_string;
20
+	/**
21
+	 * String value.
22
+	 *
23
+	 * @var string
24
+	 */
25
+	protected $_string;
26 26
 
27
-    /**
28
-     * Constructor.
29
-     *
30
-     * @param string $value String value
31
-     */
32
-    public function __construct(string $value)
33
-    {
34
-        $this->_string = $value;
35
-    }
27
+	/**
28
+	 * Constructor.
29
+	 *
30
+	 * @param string $value String value
31
+	 */
32
+	public function __construct(string $value)
33
+	{
34
+		$this->_string = $value;
35
+	}
36 36
 
37
-    /**
38
-     * {@inheritdoc}
39
-     *
40
-     * @return self
41
-     */
42
-    public static function fromASN1(UnspecifiedType $el): AttributeValue
43
-    {
44
-        return new static($el->asPrintableString()->string());
45
-    }
37
+	/**
38
+	 * {@inheritdoc}
39
+	 *
40
+	 * @return self
41
+	 */
42
+	public static function fromASN1(UnspecifiedType $el): AttributeValue
43
+	{
44
+		return new static($el->asPrintableString()->string());
45
+	}
46 46
 
47
-    /**
48
-     * {@inheritdoc}
49
-     */
50
-    public function toASN1(): Element
51
-    {
52
-        return new PrintableString($this->_string);
53
-    }
47
+	/**
48
+	 * {@inheritdoc}
49
+	 */
50
+	public function toASN1(): Element
51
+	{
52
+		return new PrintableString($this->_string);
53
+	}
54 54
 
55
-    /**
56
-     * {@inheritdoc}
57
-     */
58
-    public function stringValue(): string
59
-    {
60
-        return $this->_string;
61
-    }
55
+	/**
56
+	 * {@inheritdoc}
57
+	 */
58
+	public function stringValue(): string
59
+	{
60
+		return $this->_string;
61
+	}
62 62
 
63
-    /**
64
-     * {@inheritdoc}
65
-     */
66
-    public function equalityMatchingRule(): MatchingRule
67
-    {
68
-        // default to caseIgnoreMatch
69
-        return new CaseIgnoreMatch(Element::TYPE_PRINTABLE_STRING);
70
-    }
63
+	/**
64
+	 * {@inheritdoc}
65
+	 */
66
+	public function equalityMatchingRule(): MatchingRule
67
+	{
68
+		// default to caseIgnoreMatch
69
+		return new CaseIgnoreMatch(Element::TYPE_PRINTABLE_STRING);
70
+	}
71 71
 
72
-    /**
73
-     * {@inheritdoc}
74
-     */
75
-    public function rfc2253String(): string
76
-    {
77
-        return DNParser::escapeString($this->_transcodedString());
78
-    }
72
+	/**
73
+	 * {@inheritdoc}
74
+	 */
75
+	public function rfc2253String(): string
76
+	{
77
+		return DNParser::escapeString($this->_transcodedString());
78
+	}
79 79
 
80
-    /**
81
-     * {@inheritdoc}
82
-     */
83
-    protected function _transcodedString(): string
84
-    {
85
-        // PrintableString maps directly to UTF-8
86
-        return $this->_string;
87
-    }
80
+	/**
81
+	 * {@inheritdoc}
82
+	 */
83
+	protected function _transcodedString(): string
84
+	{
85
+		// PrintableString maps directly to UTF-8
86
+		return $this->_string;
87
+	}
88 88
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X501\ASN1\AttributeValue\Feature;
6 6
 
Please login to merge, or discard this patch.
lib/X501/ASN1/AttributeValue/SurnameValue.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -14,16 +14,16 @@
 block discarded – undo
14 14
  */
15 15
 class SurnameValue extends DirectoryString
16 16
 {
17
-    /**
18
-     * Constructor.
19
-     *
20
-     * @param string $value      String value
21
-     * @param int    $string_tag Syntax choice
22
-     */
23
-    public function __construct(string $value,
24
-        int $string_tag = DirectoryString::UTF8)
25
-    {
26
-        $this->_oid = AttributeType::OID_SURNAME;
27
-        parent::__construct($value, $string_tag);
28
-    }
17
+	/**
18
+	 * Constructor.
19
+	 *
20
+	 * @param string $value      String value
21
+	 * @param int    $string_tag Syntax choice
22
+	 */
23
+	public function __construct(string $value,
24
+		int $string_tag = DirectoryString::UTF8)
25
+	{
26
+		$this->_oid = AttributeType::OID_SURNAME;
27
+		parent::__construct($value, $string_tag);
28
+	}
29 29
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X501\ASN1\AttributeValue;
6 6
 
Please login to merge, or discard this patch.
lib/X501/ASN1/AttributeValue/UnknownAttributeValue.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -13,63 +13,63 @@
 block discarded – undo
13 13
  */
14 14
 class UnknownAttributeValue extends AttributeValue
15 15
 {
16
-    /**
17
-     * ASN.1 element.
18
-     *
19
-     * @var Element
20
-     */
21
-    protected $_element;
16
+	/**
17
+	 * ASN.1 element.
18
+	 *
19
+	 * @var Element
20
+	 */
21
+	protected $_element;
22 22
 
23
-    /**
24
-     * Constructor.
25
-     *
26
-     * @param string  $oid
27
-     * @param Element $el
28
-     */
29
-    public function __construct(string $oid, Element $el)
30
-    {
31
-        $this->_oid = $oid;
32
-        $this->_element = $el;
33
-    }
23
+	/**
24
+	 * Constructor.
25
+	 *
26
+	 * @param string  $oid
27
+	 * @param Element $el
28
+	 */
29
+	public function __construct(string $oid, Element $el)
30
+	{
31
+		$this->_oid = $oid;
32
+		$this->_element = $el;
33
+	}
34 34
 
35
-    /**
36
-     * {@inheritdoc}
37
-     */
38
-    public function toASN1(): Element
39
-    {
40
-        return $this->_element;
41
-    }
35
+	/**
36
+	 * {@inheritdoc}
37
+	 */
38
+	public function toASN1(): Element
39
+	{
40
+		return $this->_element;
41
+	}
42 42
 
43
-    /**
44
-     * {@inheritdoc}
45
-     */
46
-    public function stringValue(): string
47
-    {
48
-        // return DER encoding as a hexstring
49
-        return '#' . bin2hex($this->_element->toDER());
50
-    }
43
+	/**
44
+	 * {@inheritdoc}
45
+	 */
46
+	public function stringValue(): string
47
+	{
48
+		// return DER encoding as a hexstring
49
+		return '#' . bin2hex($this->_element->toDER());
50
+	}
51 51
 
52
-    /**
53
-     * {@inheritdoc}
54
-     */
55
-    public function equalityMatchingRule(): MatchingRule
56
-    {
57
-        return new BinaryMatch();
58
-    }
52
+	/**
53
+	 * {@inheritdoc}
54
+	 */
55
+	public function equalityMatchingRule(): MatchingRule
56
+	{
57
+		return new BinaryMatch();
58
+	}
59 59
 
60
-    /**
61
-     * {@inheritdoc}
62
-     */
63
-    public function rfc2253String(): string
64
-    {
65
-        return $this->stringValue();
66
-    }
60
+	/**
61
+	 * {@inheritdoc}
62
+	 */
63
+	public function rfc2253String(): string
64
+	{
65
+		return $this->stringValue();
66
+	}
67 67
 
68
-    /**
69
-     * {@inheritdoc}
70
-     */
71
-    protected function _transcodedString(): string
72
-    {
73
-        return $this->stringValue();
74
-    }
68
+	/**
69
+	 * {@inheritdoc}
70
+	 */
71
+	protected function _transcodedString(): string
72
+	{
73
+		return $this->stringValue();
74
+	}
75 75
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X501\ASN1\AttributeValue;
6 6
 
Please login to merge, or discard this patch.
lib/X501/ASN1/AttributeValue/PseudonymValue.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -14,16 +14,16 @@
 block discarded – undo
14 14
  */
15 15
 class PseudonymValue extends DirectoryString
16 16
 {
17
-    /**
18
-     * Constructor.
19
-     *
20
-     * @param string $value      String value
21
-     * @param int    $string_tag Syntax choice
22
-     */
23
-    public function __construct(string $value,
24
-        int $string_tag = DirectoryString::UTF8)
25
-    {
26
-        $this->_oid = AttributeType::OID_PSEUDONYM;
27
-        parent::__construct($value, $string_tag);
28
-    }
17
+	/**
18
+	 * Constructor.
19
+	 *
20
+	 * @param string $value      String value
21
+	 * @param int    $string_tag Syntax choice
22
+	 */
23
+	public function __construct(string $value,
24
+		int $string_tag = DirectoryString::UTF8)
25
+	{
26
+		$this->_oid = AttributeType::OID_PSEUDONYM;
27
+		parent::__construct($value, $string_tag);
28
+	}
29 29
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X501\ASN1\AttributeValue;
6 6
 
Please login to merge, or discard this patch.