Passed
Push — master ( 5942af...f07d61 )
by Joni
03:12
created
lib/X501/StringPrep/InsignificantNonSubstringSpaceStep.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -14,22 +14,22 @@
 block discarded – undo
14 14
  */
15 15
 class InsignificantNonSubstringSpaceStep implements PrepareStep
16 16
 {
17
-    /**
18
-     *
19
-     * @param string $string UTF-8 encoded string
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
+	 *
19
+	 * @param string $string UTF-8 encoded string
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
 }
Please login to merge, or discard this patch.
lib/X501/ASN1/AttributeType.php 1 patch
Indentation   +422 added lines, -422 removed lines patch added patch discarded remove patch
@@ -18,439 +18,439 @@
 block discarded – undo
18 18
  */
19 19
 class AttributeType
20 20
 {
21
-    // OID's from 2.5.4 arc
22
-    const OID_OBJECT_CLASS = "2.5.4.0";
23
-    const OID_ALIASED_ENTRY_NAME = "2.5.4.1";
24
-    const OID_KNOWLEDGE_INFORMATION = "2.5.4.2";
25
-    const OID_COMMON_NAME = "2.5.4.3";
26
-    const OID_SURNAME = "2.5.4.4";
27
-    const OID_SERIAL_NUMBER = "2.5.4.5";
28
-    const OID_COUNTRY_NAME = "2.5.4.6";
29
-    const OID_LOCALITY_NAME = "2.5.4.7";
30
-    const OID_STATE_OR_PROVINCE_NAME = "2.5.4.8";
31
-    const OID_STREET_ADDRESS = "2.5.4.9";
32
-    const OID_ORGANIZATION_NAME = "2.5.4.10";
33
-    const OID_ORGANIZATIONAL_UNIT_NAME = "2.5.4.11";
34
-    const OID_TITLE = "2.5.4.12";
35
-    const OID_DESCRIPTION = "2.5.4.13";
36
-    const OID_SEARCH_GUIDE = "2.5.4.14";
37
-    const OID_BUSINESS_CATEGORY = "2.5.4.15";
38
-    const OID_POSTAL_ADDRESS = "2.5.4.16";
39
-    const OID_POSTAL_CODE = "2.5.4.17";
40
-    const OID_POST_OFFICE_BOX = "2.5.4.18";
41
-    const OID_PHYSICAL_DELIVERY_OFFICE_NAME = "2.5.4.19";
42
-    const OID_TELEPHONE_NUMBER = "2.5.4.20";
43
-    const OID_TELEX_NUMBER = "2.5.4.21";
44
-    const OID_TELETEX_TERMINAL_IDENTIFIER = "2.5.4.22";
45
-    const OID_FACSIMILE_TELEPHONE_NUMBER = "2.5.4.23";
46
-    const OID_X121_ADDRESS = "2.5.4.24";
47
-    const OID_INTERNATIONAL_ISDN_NUMBER = "2.5.4.25";
48
-    const OID_REGISTERED_ADDRESS = "2.5.4.26";
49
-    const OID_DESTINATION_INDICATOR = "2.5.4.27";
50
-    const OID_PREFERRED_DELIVERY_METHOD = "2.5.4.28";
51
-    const OID_PRESENTATION_ADDRESS = "2.5.4.29";
52
-    const OID_SUPPORTED_APPLICATION_CONTEXT = "2.5.4.30";
53
-    const OID_MEMBER = "2.5.4.31";
54
-    const OID_OWNER = "2.5.4.32";
55
-    const OID_ROLE_OCCUPANT = "2.5.4.33";
56
-    const OID_SEE_ALSO = "2.5.4.34";
57
-    const OID_USER_PASSWORD = "2.5.4.35";
58
-    const OID_USER_CERTIFICATE = "2.5.4.36";
59
-    const OID_CA_CERTIFICATE = "2.5.4.37";
60
-    const OID_AUTHORITY_REVOCATION_LIST = "2.5.4.38";
61
-    const OID_CERTIFICATE_REVOCATION_LIST = "2.5.4.39";
62
-    const OID_CROSS_CERTIFICATE_PAIR = "2.5.4.40";
63
-    const OID_NAME = "2.5.4.41";
64
-    const OID_GIVEN_NAME = "2.5.4.42";
65
-    const OID_INITIALS = "2.5.4.43";
66
-    const OID_GENERATION_QUALIFIER = "2.5.4.44";
67
-    const OID_UNIQUE_IDENTIFIER = "2.5.4.45";
68
-    const OID_DN_QUALIFIER = "2.5.4.46";
69
-    const OID_ENHANCED_SEARCH_GUIDE = "2.5.4.47";
70
-    const OID_PROTOCOL_INFORMATION = "2.5.4.48";
71
-    const OID_DISTINGUISHED_NAME = "2.5.4.49";
72
-    const OID_UNIQUE_MEMBER = "2.5.4.50";
73
-    const OID_HOUSE_IDENTIFIER = "2.5.4.51";
74
-    const OID_SUPPORTED_ALGORITHMS = "2.5.4.52";
75
-    const OID_DELTA_REVOCATION_LIST = "2.5.4.53";
76
-    const OID_DMD_NAME = "2.5.4.54";
77
-    const OID_CLEARANCE = "2.5.4.55";
78
-    const OID_DEFAULT_DIR_QOP = "2.5.4.56";
79
-    const OID_ATTRIBUTE_INTEGRITY_INFO = "2.5.4.57";
80
-    const OID_ATTRIBUTE_CERTIFICATE = "2.5.4.58";
81
-    const OID_ATTRIBUTE_CERTIFICATE_REVOCATION_LIST = "2.5.4.59";
82
-    const OID_CONF_KEY_INFO = "2.5.4.60";
83
-    const OID_AA_CERTIFICATE = "2.5.4.61";
84
-    const OID_ATTRIBUTE_DESCRIPTOR_CERTIFICATE = "2.5.4.62";
85
-    const OID_ATTRIBUTE_AUTHORITY_REVOCATION_LIST = "2.5.4.63";
86
-    const OID_FAMILY_INFORMATION = "2.5.4.64";
87
-    const OID_PSEUDONYM = "2.5.4.65";
88
-    const OID_COMMUNICATIONS_SERVICE = "2.5.4.66";
89
-    const OID_COMMUNICATIONS_NETWORK = "2.5.4.67";
90
-    const OID_CERTIFICATION_PRACTICE_STMT = "2.5.4.68";
91
-    const OID_CERTIFICATE_POLICY = "2.5.4.69";
92
-    const OID_PKI_PATH = "2.5.4.70";
93
-    const OID_PRIV_POLICY = "2.5.4.71";
94
-    const OID_ROLE = "2.5.4.72";
95
-    const OID_DELEGATION_PATH = "2.5.4.73";
96
-    const OID_PROT_PRIV_POLICY = "2.5.4.74";
97
-    const OID_XML_PRIVILEGE_INFO = "2.5.4.75";
98
-    const OID_XML_PRIV_POLICY = "2.5.4.76";
99
-    const OID_UUID_PAIR = "2.5.4.77";
100
-    const OID_TAG_OID = "2.5.4.78";
101
-    const OID_UII_FORMAT = "2.5.4.79";
102
-    const OID_UII_IN_URH = "2.5.4.80";
103
-    const OID_CONTENT_URL = "2.5.4.81";
104
-    const OID_PERMISSION = "2.5.4.82";
105
-    const OID_URI = "2.5.4.83";
106
-    const OID_PWD_ATTRIBUTE = "2.5.4.84";
107
-    const OID_USER_PWD = "2.5.4.85";
108
-    const OID_URN = "2.5.4.86";
109
-    const OID_URL = "2.5.4.87";
110
-    const OID_UTM_COORDINATES = "2.5.4.88";
111
-    const OID_URNC = "2.5.4.89";
112
-    const OID_UII = "2.5.4.90";
113
-    const OID_EPC = "2.5.4.91";
114
-    const OID_TAG_AFI = "2.5.4.92";
115
-    const OID_EPC_FORMAT = "2.5.4.93";
116
-    const OID_EPC_IN_URN = "2.5.4.94";
117
-    const OID_LDAP_URL = "2.5.4.95";
118
-    const OID_TAG_LOCATION = "2.5.4.96";
119
-    const OID_ORGANIZATION_IDENTIFIER = "2.5.4.97";
21
+	// OID's from 2.5.4 arc
22
+	const OID_OBJECT_CLASS = "2.5.4.0";
23
+	const OID_ALIASED_ENTRY_NAME = "2.5.4.1";
24
+	const OID_KNOWLEDGE_INFORMATION = "2.5.4.2";
25
+	const OID_COMMON_NAME = "2.5.4.3";
26
+	const OID_SURNAME = "2.5.4.4";
27
+	const OID_SERIAL_NUMBER = "2.5.4.5";
28
+	const OID_COUNTRY_NAME = "2.5.4.6";
29
+	const OID_LOCALITY_NAME = "2.5.4.7";
30
+	const OID_STATE_OR_PROVINCE_NAME = "2.5.4.8";
31
+	const OID_STREET_ADDRESS = "2.5.4.9";
32
+	const OID_ORGANIZATION_NAME = "2.5.4.10";
33
+	const OID_ORGANIZATIONAL_UNIT_NAME = "2.5.4.11";
34
+	const OID_TITLE = "2.5.4.12";
35
+	const OID_DESCRIPTION = "2.5.4.13";
36
+	const OID_SEARCH_GUIDE = "2.5.4.14";
37
+	const OID_BUSINESS_CATEGORY = "2.5.4.15";
38
+	const OID_POSTAL_ADDRESS = "2.5.4.16";
39
+	const OID_POSTAL_CODE = "2.5.4.17";
40
+	const OID_POST_OFFICE_BOX = "2.5.4.18";
41
+	const OID_PHYSICAL_DELIVERY_OFFICE_NAME = "2.5.4.19";
42
+	const OID_TELEPHONE_NUMBER = "2.5.4.20";
43
+	const OID_TELEX_NUMBER = "2.5.4.21";
44
+	const OID_TELETEX_TERMINAL_IDENTIFIER = "2.5.4.22";
45
+	const OID_FACSIMILE_TELEPHONE_NUMBER = "2.5.4.23";
46
+	const OID_X121_ADDRESS = "2.5.4.24";
47
+	const OID_INTERNATIONAL_ISDN_NUMBER = "2.5.4.25";
48
+	const OID_REGISTERED_ADDRESS = "2.5.4.26";
49
+	const OID_DESTINATION_INDICATOR = "2.5.4.27";
50
+	const OID_PREFERRED_DELIVERY_METHOD = "2.5.4.28";
51
+	const OID_PRESENTATION_ADDRESS = "2.5.4.29";
52
+	const OID_SUPPORTED_APPLICATION_CONTEXT = "2.5.4.30";
53
+	const OID_MEMBER = "2.5.4.31";
54
+	const OID_OWNER = "2.5.4.32";
55
+	const OID_ROLE_OCCUPANT = "2.5.4.33";
56
+	const OID_SEE_ALSO = "2.5.4.34";
57
+	const OID_USER_PASSWORD = "2.5.4.35";
58
+	const OID_USER_CERTIFICATE = "2.5.4.36";
59
+	const OID_CA_CERTIFICATE = "2.5.4.37";
60
+	const OID_AUTHORITY_REVOCATION_LIST = "2.5.4.38";
61
+	const OID_CERTIFICATE_REVOCATION_LIST = "2.5.4.39";
62
+	const OID_CROSS_CERTIFICATE_PAIR = "2.5.4.40";
63
+	const OID_NAME = "2.5.4.41";
64
+	const OID_GIVEN_NAME = "2.5.4.42";
65
+	const OID_INITIALS = "2.5.4.43";
66
+	const OID_GENERATION_QUALIFIER = "2.5.4.44";
67
+	const OID_UNIQUE_IDENTIFIER = "2.5.4.45";
68
+	const OID_DN_QUALIFIER = "2.5.4.46";
69
+	const OID_ENHANCED_SEARCH_GUIDE = "2.5.4.47";
70
+	const OID_PROTOCOL_INFORMATION = "2.5.4.48";
71
+	const OID_DISTINGUISHED_NAME = "2.5.4.49";
72
+	const OID_UNIQUE_MEMBER = "2.5.4.50";
73
+	const OID_HOUSE_IDENTIFIER = "2.5.4.51";
74
+	const OID_SUPPORTED_ALGORITHMS = "2.5.4.52";
75
+	const OID_DELTA_REVOCATION_LIST = "2.5.4.53";
76
+	const OID_DMD_NAME = "2.5.4.54";
77
+	const OID_CLEARANCE = "2.5.4.55";
78
+	const OID_DEFAULT_DIR_QOP = "2.5.4.56";
79
+	const OID_ATTRIBUTE_INTEGRITY_INFO = "2.5.4.57";
80
+	const OID_ATTRIBUTE_CERTIFICATE = "2.5.4.58";
81
+	const OID_ATTRIBUTE_CERTIFICATE_REVOCATION_LIST = "2.5.4.59";
82
+	const OID_CONF_KEY_INFO = "2.5.4.60";
83
+	const OID_AA_CERTIFICATE = "2.5.4.61";
84
+	const OID_ATTRIBUTE_DESCRIPTOR_CERTIFICATE = "2.5.4.62";
85
+	const OID_ATTRIBUTE_AUTHORITY_REVOCATION_LIST = "2.5.4.63";
86
+	const OID_FAMILY_INFORMATION = "2.5.4.64";
87
+	const OID_PSEUDONYM = "2.5.4.65";
88
+	const OID_COMMUNICATIONS_SERVICE = "2.5.4.66";
89
+	const OID_COMMUNICATIONS_NETWORK = "2.5.4.67";
90
+	const OID_CERTIFICATION_PRACTICE_STMT = "2.5.4.68";
91
+	const OID_CERTIFICATE_POLICY = "2.5.4.69";
92
+	const OID_PKI_PATH = "2.5.4.70";
93
+	const OID_PRIV_POLICY = "2.5.4.71";
94
+	const OID_ROLE = "2.5.4.72";
95
+	const OID_DELEGATION_PATH = "2.5.4.73";
96
+	const OID_PROT_PRIV_POLICY = "2.5.4.74";
97
+	const OID_XML_PRIVILEGE_INFO = "2.5.4.75";
98
+	const OID_XML_PRIV_POLICY = "2.5.4.76";
99
+	const OID_UUID_PAIR = "2.5.4.77";
100
+	const OID_TAG_OID = "2.5.4.78";
101
+	const OID_UII_FORMAT = "2.5.4.79";
102
+	const OID_UII_IN_URH = "2.5.4.80";
103
+	const OID_CONTENT_URL = "2.5.4.81";
104
+	const OID_PERMISSION = "2.5.4.82";
105
+	const OID_URI = "2.5.4.83";
106
+	const OID_PWD_ATTRIBUTE = "2.5.4.84";
107
+	const OID_USER_PWD = "2.5.4.85";
108
+	const OID_URN = "2.5.4.86";
109
+	const OID_URL = "2.5.4.87";
110
+	const OID_UTM_COORDINATES = "2.5.4.88";
111
+	const OID_URNC = "2.5.4.89";
112
+	const OID_UII = "2.5.4.90";
113
+	const OID_EPC = "2.5.4.91";
114
+	const OID_TAG_AFI = "2.5.4.92";
115
+	const OID_EPC_FORMAT = "2.5.4.93";
116
+	const OID_EPC_IN_URN = "2.5.4.94";
117
+	const OID_LDAP_URL = "2.5.4.95";
118
+	const OID_TAG_LOCATION = "2.5.4.96";
119
+	const OID_ORGANIZATION_IDENTIFIER = "2.5.4.97";
120 120
     
121
-    // Miscellany attribute OID's
122
-    const OID_CLEARANCE_X501 = "2.5.1.5.55";
121
+	// Miscellany attribute OID's
122
+	const OID_CLEARANCE_X501 = "2.5.1.5.55";
123 123
     
124
-    /**
125
-     * Default ASN.1 string types for attributes.
126
-     *
127
-     * Attributes not mapped here shall use UTF8String as a default type.
128
-     *
129
-     * @internal
130
-     *
131
-     * @var array
132
-     */
133
-    const MAP_ATTR_TO_STR_TYPE = array(
134
-        /* @formatter:off */
135
-        self::OID_DN_QUALIFIER => Element::TYPE_PRINTABLE_STRING, 
136
-        self::OID_COUNTRY_NAME => Element::TYPE_PRINTABLE_STRING, 
137
-        self::OID_SERIAL_NUMBER => Element::TYPE_PRINTABLE_STRING
138
-        /* @formatter:on */
139
-    );
124
+	/**
125
+	 * Default ASN.1 string types for attributes.
126
+	 *
127
+	 * Attributes not mapped here shall use UTF8String as a default type.
128
+	 *
129
+	 * @internal
130
+	 *
131
+	 * @var array
132
+	 */
133
+	const MAP_ATTR_TO_STR_TYPE = array(
134
+		/* @formatter:off */
135
+		self::OID_DN_QUALIFIER => Element::TYPE_PRINTABLE_STRING, 
136
+		self::OID_COUNTRY_NAME => Element::TYPE_PRINTABLE_STRING, 
137
+		self::OID_SERIAL_NUMBER => Element::TYPE_PRINTABLE_STRING
138
+		/* @formatter:on */
139
+	);
140 140
     
141
-    /**
142
-     * OID to attribute names mapping.
143
-     *
144
-     * First name is the primary name. If there's more than one name, others may
145
-     * be used as an alias.
146
-     *
147
-     * Generated using ldap-attribs.py.
148
-     *
149
-     * @internal
150
-     *
151
-     * @var array
152
-     */
153
-    const MAP_OID_TO_NAME = array(
154
-        /* @formatter:off */
155
-        "0.9.2342.19200300.100.1.1" => ["uid", "userid"],
156
-        "0.9.2342.19200300.100.1.2" => ["textEncodedORAddress"],
157
-        "0.9.2342.19200300.100.1.3" => ["mail", "rfc822Mailbox"],
158
-        "0.9.2342.19200300.100.1.4" => ["info"],
159
-        "0.9.2342.19200300.100.1.5" => ["drink", "favouriteDrink"],
160
-        "0.9.2342.19200300.100.1.6" => ["roomNumber"],
161
-        "0.9.2342.19200300.100.1.7" => ["photo"],
162
-        "0.9.2342.19200300.100.1.8" => ["userClass"],
163
-        "0.9.2342.19200300.100.1.9" => ["host"],
164
-        "0.9.2342.19200300.100.1.10" => ["manager"],
165
-        "0.9.2342.19200300.100.1.11" => ["documentIdentifier"],
166
-        "0.9.2342.19200300.100.1.12" => ["documentTitle"],
167
-        "0.9.2342.19200300.100.1.13" => ["documentVersion"],
168
-        "0.9.2342.19200300.100.1.14" => ["documentAuthor"],
169
-        "0.9.2342.19200300.100.1.15" => ["documentLocation"],
170
-        "0.9.2342.19200300.100.1.20" => ["homePhone", "homeTelephoneNumber"],
171
-        "0.9.2342.19200300.100.1.21" => ["secretary"],
172
-        "0.9.2342.19200300.100.1.22" => ["otherMailbox"],
173
-        "0.9.2342.19200300.100.1.25" => ["dc", "domainComponent"],
174
-        "0.9.2342.19200300.100.1.26" => ["aRecord"],
175
-        "0.9.2342.19200300.100.1.27" => ["mDRecord"],
176
-        "0.9.2342.19200300.100.1.28" => ["mXRecord"],
177
-        "0.9.2342.19200300.100.1.29" => ["nSRecord"],
178
-        "0.9.2342.19200300.100.1.30" => ["sOARecord"],
179
-        "0.9.2342.19200300.100.1.31" => ["cNAMERecord"],
180
-        "0.9.2342.19200300.100.1.37" => ["associatedDomain"],
181
-        "0.9.2342.19200300.100.1.38" => ["associatedName"],
182
-        "0.9.2342.19200300.100.1.39" => ["homePostalAddress"],
183
-        "0.9.2342.19200300.100.1.40" => ["personalTitle"],
184
-        "0.9.2342.19200300.100.1.41" => ["mobile", "mobileTelephoneNumber"],
185
-        "0.9.2342.19200300.100.1.42" => ["pager", "pagerTelephoneNumber"],
186
-        "0.9.2342.19200300.100.1.43" => ["co", "friendlyCountryName"],
187
-        "0.9.2342.19200300.100.1.44" => ["uniqueIdentifier"],
188
-        "0.9.2342.19200300.100.1.45" => ["organizationalStatus"],
189
-        "0.9.2342.19200300.100.1.46" => ["janetMailbox"],
190
-        "0.9.2342.19200300.100.1.47" => ["mailPreferenceOption"],
191
-        "0.9.2342.19200300.100.1.48" => ["buildingName"],
192
-        "0.9.2342.19200300.100.1.49" => ["dSAQuality"],
193
-        "0.9.2342.19200300.100.1.50" => ["singleLevelQuality"],
194
-        "0.9.2342.19200300.100.1.51" => ["subtreeMinimumQuality"],
195
-        "0.9.2342.19200300.100.1.52" => ["subtreeMaximumQuality"],
196
-        "0.9.2342.19200300.100.1.53" => ["personalSignature"],
197
-        "0.9.2342.19200300.100.1.54" => ["dITRedirect"],
198
-        "0.9.2342.19200300.100.1.55" => ["audio"],
199
-        "0.9.2342.19200300.100.1.56" => ["documentPublisher"],
200
-        "0.9.2342.19200300.100.1.60" => ["jpegPhoto"],
201
-        "1.2.840.113549.1.9.1" => ["email", "emailAddress", "pkcs9email"],
202
-        "1.2.840.113556.1.2.102" => ["memberOf"],
203
-        "1.3.6.1.1.1.1.0" => ["uidNumber"],
204
-        "1.3.6.1.1.1.1.1" => ["gidNumber"],
205
-        "1.3.6.1.1.1.1.2" => ["gecos"],
206
-        "1.3.6.1.1.1.1.3" => ["homeDirectory"],
207
-        "1.3.6.1.1.1.1.4" => ["loginShell"],
208
-        "1.3.6.1.1.1.1.5" => ["shadowLastChange"],
209
-        "1.3.6.1.1.1.1.6" => ["shadowMin"],
210
-        "1.3.6.1.1.1.1.7" => ["shadowMax"],
211
-        "1.3.6.1.1.1.1.8" => ["shadowWarning"],
212
-        "1.3.6.1.1.1.1.9" => ["shadowInactive"],
213
-        "1.3.6.1.1.1.1.10" => ["shadowExpire"],
214
-        "1.3.6.1.1.1.1.11" => ["shadowFlag"],
215
-        "1.3.6.1.1.1.1.12" => ["memberUid"],
216
-        "1.3.6.1.1.1.1.13" => ["memberNisNetgroup"],
217
-        "1.3.6.1.1.1.1.14" => ["nisNetgroupTriple"],
218
-        "1.3.6.1.1.1.1.15" => ["ipServicePort"],
219
-        "1.3.6.1.1.1.1.16" => ["ipServiceProtocol"],
220
-        "1.3.6.1.1.1.1.17" => ["ipProtocolNumber"],
221
-        "1.3.6.1.1.1.1.18" => ["oncRpcNumber"],
222
-        "1.3.6.1.1.1.1.19" => ["ipHostNumber"],
223
-        "1.3.6.1.1.1.1.20" => ["ipNetworkNumber"],
224
-        "1.3.6.1.1.1.1.21" => ["ipNetmaskNumber"],
225
-        "1.3.6.1.1.1.1.22" => ["macAddress"],
226
-        "1.3.6.1.1.1.1.23" => ["bootParameter"],
227
-        "1.3.6.1.1.1.1.24" => ["bootFile"],
228
-        "1.3.6.1.1.1.1.26" => ["nisMapName"],
229
-        "1.3.6.1.1.1.1.27" => ["nisMapEntry"],
230
-        "1.3.6.1.1.4" => ["vendorName"],
231
-        "1.3.6.1.1.5" => ["vendorVersion"],
232
-        "1.3.6.1.1.16.4" => ["entryUUID"],
233
-        "1.3.6.1.1.20" => ["entryDN"],
234
-        "2.5.4.0" => ["objectClass"],
235
-        "2.5.4.1" => ["aliasedObjectName", "aliasedEntryName"],
236
-        "2.5.4.2" => ["knowledgeInformation"],
237
-        "2.5.4.3" => ["cn", "commonName"],
238
-        "2.5.4.4" => ["sn", "surname"],
239
-        "2.5.4.5" => ["serialNumber"],
240
-        "2.5.4.6" => ["c", "countryName"],
241
-        "2.5.4.7" => ["l", "localityName"],
242
-        "2.5.4.8" => ["st", "stateOrProvinceName"],
243
-        "2.5.4.9" => ["street", "streetAddress"],
244
-        "2.5.4.10" => ["o", "organizationName"],
245
-        "2.5.4.11" => ["ou", "organizationalUnitName"],
246
-        "2.5.4.12" => ["title"],
247
-        "2.5.4.13" => ["description"],
248
-        "2.5.4.14" => ["searchGuide"],
249
-        "2.5.4.15" => ["businessCategory"],
250
-        "2.5.4.16" => ["postalAddress"],
251
-        "2.5.4.17" => ["postalCode"],
252
-        "2.5.4.18" => ["postOfficeBox"],
253
-        "2.5.4.19" => ["physicalDeliveryOfficeName"],
254
-        "2.5.4.20" => ["telephoneNumber"],
255
-        "2.5.4.21" => ["telexNumber"],
256
-        "2.5.4.22" => ["teletexTerminalIdentifier"],
257
-        "2.5.4.23" => ["facsimileTelephoneNumber", "fax"],
258
-        "2.5.4.24" => ["x121Address"],
259
-        "2.5.4.25" => ["internationaliSDNNumber"],
260
-        "2.5.4.26" => ["registeredAddress"],
261
-        "2.5.4.27" => ["destinationIndicator"],
262
-        "2.5.4.28" => ["preferredDeliveryMethod"],
263
-        "2.5.4.29" => ["presentationAddress"],
264
-        "2.5.4.30" => ["supportedApplicationContext"],
265
-        "2.5.4.31" => ["member"],
266
-        "2.5.4.32" => ["owner"],
267
-        "2.5.4.33" => ["roleOccupant"],
268
-        "2.5.4.34" => ["seeAlso"],
269
-        "2.5.4.35" => ["userPassword"],
270
-        "2.5.4.36" => ["userCertificate"],
271
-        "2.5.4.37" => ["cACertificate"],
272
-        "2.5.4.38" => ["authorityRevocationList"],
273
-        "2.5.4.39" => ["certificateRevocationList"],
274
-        "2.5.4.40" => ["crossCertificatePair"],
275
-        "2.5.4.41" => ["name"],
276
-        "2.5.4.42" => ["givenName", "gn"],
277
-        "2.5.4.43" => ["initials"],
278
-        "2.5.4.44" => ["generationQualifier"],
279
-        "2.5.4.45" => ["x500UniqueIdentifier"],
280
-        "2.5.4.46" => ["dnQualifier"],
281
-        "2.5.4.47" => ["enhancedSearchGuide"],
282
-        "2.5.4.48" => ["protocolInformation"],
283
-        "2.5.4.49" => ["distinguishedName"],
284
-        "2.5.4.50" => ["uniqueMember"],
285
-        "2.5.4.51" => ["houseIdentifier"],
286
-        "2.5.4.52" => ["supportedAlgorithms"],
287
-        "2.5.4.53" => ["deltaRevocationList"],
288
-        "2.5.4.54" => ["dmdName"],
289
-        "2.5.4.65" => ["pseudonym"],
290
-        "2.5.18.1" => ["createTimestamp"],
291
-        "2.5.18.2" => ["modifyTimestamp"],
292
-        "2.5.18.3" => ["creatorsName"],
293
-        "2.5.18.4" => ["modifiersName"],
294
-        "2.5.18.5" => ["administrativeRole"],
295
-        "2.5.18.6" => ["subtreeSpecification"],
296
-        "2.5.18.9" => ["hasSubordinates"],
297
-        "2.5.18.10" => ["subschemaSubentry"],
298
-        "2.5.21.1" => ["dITStructureRules"],
299
-        "2.5.21.2" => ["dITContentRules"],
300
-        "2.5.21.4" => ["matchingRules"],
301
-        "2.5.21.5" => ["attributeTypes"],
302
-        "2.5.21.6" => ["objectClasses"],
303
-        "2.5.21.7" => ["nameForms"],
304
-        "2.5.21.8" => ["matchingRuleUse"],
305
-        "2.5.21.9" => ["structuralObjectClass"],
306
-        "2.16.840.1.113730.3.1.1" => ["carLicense"],
307
-        "2.16.840.1.113730.3.1.2" => ["departmentNumber"],
308
-        "2.16.840.1.113730.3.1.3" => ["employeeNumber"],
309
-        "2.16.840.1.113730.3.1.4" => ["employeeType"],
310
-        "2.16.840.1.113730.3.1.34" => ["ref"],
311
-        "2.16.840.1.113730.3.1.39" => ["preferredLanguage"],
312
-        "2.16.840.1.113730.3.1.40" => ["userSMIMECertificate"],
313
-        "2.16.840.1.113730.3.1.216" => ["userPKCS12"],
314
-        "2.16.840.1.113730.3.1.241" => ["displayName"]
315
-        /* @formatter:on */
316
-    );
141
+	/**
142
+	 * OID to attribute names mapping.
143
+	 *
144
+	 * First name is the primary name. If there's more than one name, others may
145
+	 * be used as an alias.
146
+	 *
147
+	 * Generated using ldap-attribs.py.
148
+	 *
149
+	 * @internal
150
+	 *
151
+	 * @var array
152
+	 */
153
+	const MAP_OID_TO_NAME = array(
154
+		/* @formatter:off */
155
+		"0.9.2342.19200300.100.1.1" => ["uid", "userid"],
156
+		"0.9.2342.19200300.100.1.2" => ["textEncodedORAddress"],
157
+		"0.9.2342.19200300.100.1.3" => ["mail", "rfc822Mailbox"],
158
+		"0.9.2342.19200300.100.1.4" => ["info"],
159
+		"0.9.2342.19200300.100.1.5" => ["drink", "favouriteDrink"],
160
+		"0.9.2342.19200300.100.1.6" => ["roomNumber"],
161
+		"0.9.2342.19200300.100.1.7" => ["photo"],
162
+		"0.9.2342.19200300.100.1.8" => ["userClass"],
163
+		"0.9.2342.19200300.100.1.9" => ["host"],
164
+		"0.9.2342.19200300.100.1.10" => ["manager"],
165
+		"0.9.2342.19200300.100.1.11" => ["documentIdentifier"],
166
+		"0.9.2342.19200300.100.1.12" => ["documentTitle"],
167
+		"0.9.2342.19200300.100.1.13" => ["documentVersion"],
168
+		"0.9.2342.19200300.100.1.14" => ["documentAuthor"],
169
+		"0.9.2342.19200300.100.1.15" => ["documentLocation"],
170
+		"0.9.2342.19200300.100.1.20" => ["homePhone", "homeTelephoneNumber"],
171
+		"0.9.2342.19200300.100.1.21" => ["secretary"],
172
+		"0.9.2342.19200300.100.1.22" => ["otherMailbox"],
173
+		"0.9.2342.19200300.100.1.25" => ["dc", "domainComponent"],
174
+		"0.9.2342.19200300.100.1.26" => ["aRecord"],
175
+		"0.9.2342.19200300.100.1.27" => ["mDRecord"],
176
+		"0.9.2342.19200300.100.1.28" => ["mXRecord"],
177
+		"0.9.2342.19200300.100.1.29" => ["nSRecord"],
178
+		"0.9.2342.19200300.100.1.30" => ["sOARecord"],
179
+		"0.9.2342.19200300.100.1.31" => ["cNAMERecord"],
180
+		"0.9.2342.19200300.100.1.37" => ["associatedDomain"],
181
+		"0.9.2342.19200300.100.1.38" => ["associatedName"],
182
+		"0.9.2342.19200300.100.1.39" => ["homePostalAddress"],
183
+		"0.9.2342.19200300.100.1.40" => ["personalTitle"],
184
+		"0.9.2342.19200300.100.1.41" => ["mobile", "mobileTelephoneNumber"],
185
+		"0.9.2342.19200300.100.1.42" => ["pager", "pagerTelephoneNumber"],
186
+		"0.9.2342.19200300.100.1.43" => ["co", "friendlyCountryName"],
187
+		"0.9.2342.19200300.100.1.44" => ["uniqueIdentifier"],
188
+		"0.9.2342.19200300.100.1.45" => ["organizationalStatus"],
189
+		"0.9.2342.19200300.100.1.46" => ["janetMailbox"],
190
+		"0.9.2342.19200300.100.1.47" => ["mailPreferenceOption"],
191
+		"0.9.2342.19200300.100.1.48" => ["buildingName"],
192
+		"0.9.2342.19200300.100.1.49" => ["dSAQuality"],
193
+		"0.9.2342.19200300.100.1.50" => ["singleLevelQuality"],
194
+		"0.9.2342.19200300.100.1.51" => ["subtreeMinimumQuality"],
195
+		"0.9.2342.19200300.100.1.52" => ["subtreeMaximumQuality"],
196
+		"0.9.2342.19200300.100.1.53" => ["personalSignature"],
197
+		"0.9.2342.19200300.100.1.54" => ["dITRedirect"],
198
+		"0.9.2342.19200300.100.1.55" => ["audio"],
199
+		"0.9.2342.19200300.100.1.56" => ["documentPublisher"],
200
+		"0.9.2342.19200300.100.1.60" => ["jpegPhoto"],
201
+		"1.2.840.113549.1.9.1" => ["email", "emailAddress", "pkcs9email"],
202
+		"1.2.840.113556.1.2.102" => ["memberOf"],
203
+		"1.3.6.1.1.1.1.0" => ["uidNumber"],
204
+		"1.3.6.1.1.1.1.1" => ["gidNumber"],
205
+		"1.3.6.1.1.1.1.2" => ["gecos"],
206
+		"1.3.6.1.1.1.1.3" => ["homeDirectory"],
207
+		"1.3.6.1.1.1.1.4" => ["loginShell"],
208
+		"1.3.6.1.1.1.1.5" => ["shadowLastChange"],
209
+		"1.3.6.1.1.1.1.6" => ["shadowMin"],
210
+		"1.3.6.1.1.1.1.7" => ["shadowMax"],
211
+		"1.3.6.1.1.1.1.8" => ["shadowWarning"],
212
+		"1.3.6.1.1.1.1.9" => ["shadowInactive"],
213
+		"1.3.6.1.1.1.1.10" => ["shadowExpire"],
214
+		"1.3.6.1.1.1.1.11" => ["shadowFlag"],
215
+		"1.3.6.1.1.1.1.12" => ["memberUid"],
216
+		"1.3.6.1.1.1.1.13" => ["memberNisNetgroup"],
217
+		"1.3.6.1.1.1.1.14" => ["nisNetgroupTriple"],
218
+		"1.3.6.1.1.1.1.15" => ["ipServicePort"],
219
+		"1.3.6.1.1.1.1.16" => ["ipServiceProtocol"],
220
+		"1.3.6.1.1.1.1.17" => ["ipProtocolNumber"],
221
+		"1.3.6.1.1.1.1.18" => ["oncRpcNumber"],
222
+		"1.3.6.1.1.1.1.19" => ["ipHostNumber"],
223
+		"1.3.6.1.1.1.1.20" => ["ipNetworkNumber"],
224
+		"1.3.6.1.1.1.1.21" => ["ipNetmaskNumber"],
225
+		"1.3.6.1.1.1.1.22" => ["macAddress"],
226
+		"1.3.6.1.1.1.1.23" => ["bootParameter"],
227
+		"1.3.6.1.1.1.1.24" => ["bootFile"],
228
+		"1.3.6.1.1.1.1.26" => ["nisMapName"],
229
+		"1.3.6.1.1.1.1.27" => ["nisMapEntry"],
230
+		"1.3.6.1.1.4" => ["vendorName"],
231
+		"1.3.6.1.1.5" => ["vendorVersion"],
232
+		"1.3.6.1.1.16.4" => ["entryUUID"],
233
+		"1.3.6.1.1.20" => ["entryDN"],
234
+		"2.5.4.0" => ["objectClass"],
235
+		"2.5.4.1" => ["aliasedObjectName", "aliasedEntryName"],
236
+		"2.5.4.2" => ["knowledgeInformation"],
237
+		"2.5.4.3" => ["cn", "commonName"],
238
+		"2.5.4.4" => ["sn", "surname"],
239
+		"2.5.4.5" => ["serialNumber"],
240
+		"2.5.4.6" => ["c", "countryName"],
241
+		"2.5.4.7" => ["l", "localityName"],
242
+		"2.5.4.8" => ["st", "stateOrProvinceName"],
243
+		"2.5.4.9" => ["street", "streetAddress"],
244
+		"2.5.4.10" => ["o", "organizationName"],
245
+		"2.5.4.11" => ["ou", "organizationalUnitName"],
246
+		"2.5.4.12" => ["title"],
247
+		"2.5.4.13" => ["description"],
248
+		"2.5.4.14" => ["searchGuide"],
249
+		"2.5.4.15" => ["businessCategory"],
250
+		"2.5.4.16" => ["postalAddress"],
251
+		"2.5.4.17" => ["postalCode"],
252
+		"2.5.4.18" => ["postOfficeBox"],
253
+		"2.5.4.19" => ["physicalDeliveryOfficeName"],
254
+		"2.5.4.20" => ["telephoneNumber"],
255
+		"2.5.4.21" => ["telexNumber"],
256
+		"2.5.4.22" => ["teletexTerminalIdentifier"],
257
+		"2.5.4.23" => ["facsimileTelephoneNumber", "fax"],
258
+		"2.5.4.24" => ["x121Address"],
259
+		"2.5.4.25" => ["internationaliSDNNumber"],
260
+		"2.5.4.26" => ["registeredAddress"],
261
+		"2.5.4.27" => ["destinationIndicator"],
262
+		"2.5.4.28" => ["preferredDeliveryMethod"],
263
+		"2.5.4.29" => ["presentationAddress"],
264
+		"2.5.4.30" => ["supportedApplicationContext"],
265
+		"2.5.4.31" => ["member"],
266
+		"2.5.4.32" => ["owner"],
267
+		"2.5.4.33" => ["roleOccupant"],
268
+		"2.5.4.34" => ["seeAlso"],
269
+		"2.5.4.35" => ["userPassword"],
270
+		"2.5.4.36" => ["userCertificate"],
271
+		"2.5.4.37" => ["cACertificate"],
272
+		"2.5.4.38" => ["authorityRevocationList"],
273
+		"2.5.4.39" => ["certificateRevocationList"],
274
+		"2.5.4.40" => ["crossCertificatePair"],
275
+		"2.5.4.41" => ["name"],
276
+		"2.5.4.42" => ["givenName", "gn"],
277
+		"2.5.4.43" => ["initials"],
278
+		"2.5.4.44" => ["generationQualifier"],
279
+		"2.5.4.45" => ["x500UniqueIdentifier"],
280
+		"2.5.4.46" => ["dnQualifier"],
281
+		"2.5.4.47" => ["enhancedSearchGuide"],
282
+		"2.5.4.48" => ["protocolInformation"],
283
+		"2.5.4.49" => ["distinguishedName"],
284
+		"2.5.4.50" => ["uniqueMember"],
285
+		"2.5.4.51" => ["houseIdentifier"],
286
+		"2.5.4.52" => ["supportedAlgorithms"],
287
+		"2.5.4.53" => ["deltaRevocationList"],
288
+		"2.5.4.54" => ["dmdName"],
289
+		"2.5.4.65" => ["pseudonym"],
290
+		"2.5.18.1" => ["createTimestamp"],
291
+		"2.5.18.2" => ["modifyTimestamp"],
292
+		"2.5.18.3" => ["creatorsName"],
293
+		"2.5.18.4" => ["modifiersName"],
294
+		"2.5.18.5" => ["administrativeRole"],
295
+		"2.5.18.6" => ["subtreeSpecification"],
296
+		"2.5.18.9" => ["hasSubordinates"],
297
+		"2.5.18.10" => ["subschemaSubentry"],
298
+		"2.5.21.1" => ["dITStructureRules"],
299
+		"2.5.21.2" => ["dITContentRules"],
300
+		"2.5.21.4" => ["matchingRules"],
301
+		"2.5.21.5" => ["attributeTypes"],
302
+		"2.5.21.6" => ["objectClasses"],
303
+		"2.5.21.7" => ["nameForms"],
304
+		"2.5.21.8" => ["matchingRuleUse"],
305
+		"2.5.21.9" => ["structuralObjectClass"],
306
+		"2.16.840.1.113730.3.1.1" => ["carLicense"],
307
+		"2.16.840.1.113730.3.1.2" => ["departmentNumber"],
308
+		"2.16.840.1.113730.3.1.3" => ["employeeNumber"],
309
+		"2.16.840.1.113730.3.1.4" => ["employeeType"],
310
+		"2.16.840.1.113730.3.1.34" => ["ref"],
311
+		"2.16.840.1.113730.3.1.39" => ["preferredLanguage"],
312
+		"2.16.840.1.113730.3.1.40" => ["userSMIMECertificate"],
313
+		"2.16.840.1.113730.3.1.216" => ["userPKCS12"],
314
+		"2.16.840.1.113730.3.1.241" => ["displayName"]
315
+		/* @formatter:on */
316
+	);
317 317
     
318
-    /**
319
-     * OID of the attribute.
320
-     *
321
-     * @var string $_oid
322
-     */
323
-    protected $_oid;
318
+	/**
319
+	 * OID of the attribute.
320
+	 *
321
+	 * @var string $_oid
322
+	 */
323
+	protected $_oid;
324 324
     
325
-    /**
326
-     * Constructor.
327
-     *
328
-     * @param string $oid OID in dotted format.
329
-     */
330
-    public function __construct(string $oid)
331
-    {
332
-        $this->_oid = $oid;
333
-    }
325
+	/**
326
+	 * Constructor.
327
+	 *
328
+	 * @param string $oid OID in dotted format.
329
+	 */
330
+	public function __construct(string $oid)
331
+	{
332
+		$this->_oid = $oid;
333
+	}
334 334
     
335
-    /**
336
-     * Initialize from ASN.1.
337
-     *
338
-     * @param ObjectIdentifier $oi
339
-     * @return self
340
-     */
341
-    public static function fromASN1(ObjectIdentifier $oi): self
342
-    {
343
-        return new self($oi->oid());
344
-    }
335
+	/**
336
+	 * Initialize from ASN.1.
337
+	 *
338
+	 * @param ObjectIdentifier $oi
339
+	 * @return self
340
+	 */
341
+	public static function fromASN1(ObjectIdentifier $oi): self
342
+	{
343
+		return new self($oi->oid());
344
+	}
345 345
     
346
-    /**
347
-     * Initialize from attribute name.
348
-     *
349
-     * @param string $name
350
-     * @return self
351
-     */
352
-    public static function fromName(string $name): self
353
-    {
354
-        $oid = self::attrNameToOID($name);
355
-        return new self($oid);
356
-    }
346
+	/**
347
+	 * Initialize from attribute name.
348
+	 *
349
+	 * @param string $name
350
+	 * @return self
351
+	 */
352
+	public static function fromName(string $name): self
353
+	{
354
+		$oid = self::attrNameToOID($name);
355
+		return new self($oid);
356
+	}
357 357
     
358
-    /**
359
-     * Get OID of the attribute.
360
-     *
361
-     * @return string OID in dotted format
362
-     */
363
-    public function oid(): string
364
-    {
365
-        return $this->_oid;
366
-    }
358
+	/**
359
+	 * Get OID of the attribute.
360
+	 *
361
+	 * @return string OID in dotted format
362
+	 */
363
+	public function oid(): string
364
+	{
365
+		return $this->_oid;
366
+	}
367 367
     
368
-    /**
369
-     * Get name of the attribute.
370
-     *
371
-     * @return string
372
-     */
373
-    public function typeName(): string
374
-    {
375
-        if (array_key_exists($this->_oid, self::MAP_OID_TO_NAME)) {
376
-            return self::MAP_OID_TO_NAME[$this->_oid][0];
377
-        }
378
-        return $this->_oid;
379
-    }
368
+	/**
369
+	 * Get name of the attribute.
370
+	 *
371
+	 * @return string
372
+	 */
373
+	public function typeName(): string
374
+	{
375
+		if (array_key_exists($this->_oid, self::MAP_OID_TO_NAME)) {
376
+			return self::MAP_OID_TO_NAME[$this->_oid][0];
377
+		}
378
+		return $this->_oid;
379
+	}
380 380
     
381
-    /**
382
-     * Generate ASN.1 element.
383
-     *
384
-     * @return ObjectIdentifier
385
-     */
386
-    public function toASN1(): ObjectIdentifier
387
-    {
388
-        return new ObjectIdentifier($this->_oid);
389
-    }
381
+	/**
382
+	 * Generate ASN.1 element.
383
+	 *
384
+	 * @return ObjectIdentifier
385
+	 */
386
+	public function toASN1(): ObjectIdentifier
387
+	{
388
+		return new ObjectIdentifier($this->_oid);
389
+	}
390 390
     
391
-    /**
392
-     * Get name to OID lookup map.
393
-     *
394
-     * @return array
395
-     */
396
-    private static function _oidReverseMap(): array
397
-    {
398
-        static $map;
399
-        if (!isset($map)) {
400
-            $map = array();
401
-            // for eatch attribute type
402
-            foreach (self::MAP_OID_TO_NAME as $oid => $names) {
403
-                // for primary name and aliases
404
-                foreach ($names as $name) {
405
-                    $map[strtolower($name)] = $oid;
406
-                }
407
-            }
408
-        }
409
-        return $map;
410
-    }
391
+	/**
392
+	 * Get name to OID lookup map.
393
+	 *
394
+	 * @return array
395
+	 */
396
+	private static function _oidReverseMap(): array
397
+	{
398
+		static $map;
399
+		if (!isset($map)) {
400
+			$map = array();
401
+			// for eatch attribute type
402
+			foreach (self::MAP_OID_TO_NAME as $oid => $names) {
403
+				// for primary name and aliases
404
+				foreach ($names as $name) {
405
+					$map[strtolower($name)] = $oid;
406
+				}
407
+			}
408
+		}
409
+		return $map;
410
+	}
411 411
     
412
-    /**
413
-     * Convert attribute name to OID.
414
-     *
415
-     * @param string $name Primary attribute name or an alias
416
-     * @throws \OutOfBoundsException
417
-     * @return string OID in dotted format
418
-     */
419
-    public static function attrNameToOID(string $name): string
420
-    {
421
-        // if already in OID form
422
-        if (preg_match('/^[0-9]+(?:\.[0-9]+)*$/', $name)) {
423
-            return $name;
424
-        }
425
-        $map = self::_oidReverseMap();
426
-        $k = strtolower($name);
427
-        if (!isset($map[$k])) {
428
-            throw new \OutOfBoundsException("No OID for $name.");
429
-        }
430
-        return $map[$k];
431
-    }
412
+	/**
413
+	 * Convert attribute name to OID.
414
+	 *
415
+	 * @param string $name Primary attribute name or an alias
416
+	 * @throws \OutOfBoundsException
417
+	 * @return string OID in dotted format
418
+	 */
419
+	public static function attrNameToOID(string $name): string
420
+	{
421
+		// if already in OID form
422
+		if (preg_match('/^[0-9]+(?:\.[0-9]+)*$/', $name)) {
423
+			return $name;
424
+		}
425
+		$map = self::_oidReverseMap();
426
+		$k = strtolower($name);
427
+		if (!isset($map[$k])) {
428
+			throw new \OutOfBoundsException("No OID for $name.");
429
+		}
430
+		return $map[$k];
431
+	}
432 432
     
433
-    /**
434
-     * Get ASN.1 string for given attribute type.
435
-     *
436
-     * @param string $oid Attribute OID
437
-     * @param string $str String
438
-     * @throws \LogicException
439
-     * @return \ASN1\Type\StringType
440
-     */
441
-    public static function asn1StringForType(string $oid, string $str): StringType
442
-    {
443
-        if (!array_key_exists($oid, self::MAP_ATTR_TO_STR_TYPE)) {
444
-            return new UTF8String($str);
445
-        }
446
-        switch (self::MAP_ATTR_TO_STR_TYPE[$oid]) {
447
-            case Element::TYPE_PRINTABLE_STRING:
448
-                return new PrintableString($str);
449
-            // @codeCoverageIgnoreStart
450
-            default:
451
-                // only reachable during development
452
-                throw new \LogicException();
453
-        }
454
-        // @codeCoverageIgnoreEnd
455
-    }
433
+	/**
434
+	 * Get ASN.1 string for given attribute type.
435
+	 *
436
+	 * @param string $oid Attribute OID
437
+	 * @param string $str String
438
+	 * @throws \LogicException
439
+	 * @return \ASN1\Type\StringType
440
+	 */
441
+	public static function asn1StringForType(string $oid, string $str): StringType
442
+	{
443
+		if (!array_key_exists($oid, self::MAP_ATTR_TO_STR_TYPE)) {
444
+			return new UTF8String($str);
445
+		}
446
+		switch (self::MAP_ATTR_TO_STR_TYPE[$oid]) {
447
+			case Element::TYPE_PRINTABLE_STRING:
448
+				return new PrintableString($str);
449
+			// @codeCoverageIgnoreStart
450
+			default:
451
+				// only reachable during development
452
+				throw new \LogicException();
453
+		}
454
+		// @codeCoverageIgnoreEnd
455
+	}
456 456
 }
Please login to merge, or discard this patch.
lib/X501/ASN1/Feature/TypedAttribute.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -11,30 +11,30 @@
 block discarded – undo
11 11
  */
12 12
 trait TypedAttribute
13 13
 {
14
-    /**
15
-     * Attribute type.
16
-     *
17
-     * @var AttributeType $_type
18
-     */
19
-    protected $_type;
14
+	/**
15
+	 * Attribute type.
16
+	 *
17
+	 * @var AttributeType $_type
18
+	 */
19
+	protected $_type;
20 20
     
21
-    /**
22
-     * Get attribute type.
23
-     *
24
-     * @return AttributeType
25
-     */
26
-    public function type(): AttributeType
27
-    {
28
-        return $this->_type;
29
-    }
21
+	/**
22
+	 * Get attribute type.
23
+	 *
24
+	 * @return AttributeType
25
+	 */
26
+	public function type(): AttributeType
27
+	{
28
+		return $this->_type;
29
+	}
30 30
     
31
-    /**
32
-     * Get OID of the attribute.
33
-     *
34
-     * @return string
35
-     */
36
-    public function oid(): string
37
-    {
38
-        return $this->_type->oid();
39
-    }
31
+	/**
32
+	 * Get OID of the attribute.
33
+	 *
34
+	 * @return string
35
+	 */
36
+	public function oid(): string
37
+	{
38
+		return $this->_type->oid();
39
+	}
40 40
 }
Please login to merge, or discard this patch.
lib/X501/ASN1/Name.php 2 patches
Indentation   +183 added lines, -183 removed lines patch added patch discarded remove patch
@@ -21,199 +21,199 @@
 block discarded – undo
21 21
  */
22 22
 class Name implements \Countable, \IteratorAggregate
23 23
 {
24
-    /**
25
-     * Relative distinguished name components.
26
-     *
27
-     * @var RDN[] $_rdns
28
-     */
29
-    protected $_rdns;
24
+	/**
25
+	 * Relative distinguished name components.
26
+	 *
27
+	 * @var RDN[] $_rdns
28
+	 */
29
+	protected $_rdns;
30 30
     
31
-    /**
32
-     * Constructor.
33
-     *
34
-     * @param RDN ...$rdns RDN components
35
-     */
36
-    public function __construct(RDN ...$rdns)
37
-    {
38
-        $this->_rdns = $rdns;
39
-    }
31
+	/**
32
+	 * Constructor.
33
+	 *
34
+	 * @param RDN ...$rdns RDN components
35
+	 */
36
+	public function __construct(RDN ...$rdns)
37
+	{
38
+		$this->_rdns = $rdns;
39
+	}
40 40
     
41
-    /**
42
-     * Initialize from ASN.1.
43
-     *
44
-     * @param Sequence $seq
45
-     * @return self
46
-     */
47
-    public static function fromASN1(Sequence $seq): self
48
-    {
49
-        $rdns = array_map(
50
-            function (UnspecifiedType $el) {
51
-                return RDN::fromASN1($el->asSet());
52
-            }, $seq->elements());
53
-        return new self(...$rdns);
54
-    }
41
+	/**
42
+	 * Initialize from ASN.1.
43
+	 *
44
+	 * @param Sequence $seq
45
+	 * @return self
46
+	 */
47
+	public static function fromASN1(Sequence $seq): self
48
+	{
49
+		$rdns = array_map(
50
+			function (UnspecifiedType $el) {
51
+				return RDN::fromASN1($el->asSet());
52
+			}, $seq->elements());
53
+		return new self(...$rdns);
54
+	}
55 55
     
56
-    /**
57
-     * Initialize from distinguished name string.
58
-     *
59
-     * @link https://tools.ietf.org/html/rfc1779
60
-     * @param string $str
61
-     * @return self
62
-     */
63
-    public static function fromString(string $str): self
64
-    {
65
-        $rdns = array();
66
-        foreach (DNParser::parseString($str) as $nameComponent) {
67
-            $attribs = array();
68
-            foreach ($nameComponent as list($name, $val)) {
69
-                $type = AttributeType::fromName($name);
70
-                // hexstrings are parsed to ASN.1 elements
71
-                if ($val instanceof Element) {
72
-                    $el = $val;
73
-                } else {
74
-                    $el = AttributeType::asn1StringForType($type->oid(), $val);
75
-                }
76
-                $value = AttributeValue::fromASN1ByOID($type->oid(),
77
-                    $el->asUnspecified());
78
-                $attribs[] = new AttributeTypeAndValue($type, $value);
79
-            }
80
-            $rdns[] = new RDN(...$attribs);
81
-        }
82
-        return new self(...$rdns);
83
-    }
56
+	/**
57
+	 * Initialize from distinguished name string.
58
+	 *
59
+	 * @link https://tools.ietf.org/html/rfc1779
60
+	 * @param string $str
61
+	 * @return self
62
+	 */
63
+	public static function fromString(string $str): self
64
+	{
65
+		$rdns = array();
66
+		foreach (DNParser::parseString($str) as $nameComponent) {
67
+			$attribs = array();
68
+			foreach ($nameComponent as list($name, $val)) {
69
+				$type = AttributeType::fromName($name);
70
+				// hexstrings are parsed to ASN.1 elements
71
+				if ($val instanceof Element) {
72
+					$el = $val;
73
+				} else {
74
+					$el = AttributeType::asn1StringForType($type->oid(), $val);
75
+				}
76
+				$value = AttributeValue::fromASN1ByOID($type->oid(),
77
+					$el->asUnspecified());
78
+				$attribs[] = new AttributeTypeAndValue($type, $value);
79
+			}
80
+			$rdns[] = new RDN(...$attribs);
81
+		}
82
+		return new self(...$rdns);
83
+	}
84 84
     
85
-    /**
86
-     * Generate ASN.1 structure.
87
-     *
88
-     * @return Sequence
89
-     */
90
-    public function toASN1(): Sequence
91
-    {
92
-        $elements = array_map(
93
-            function (RDN $rdn) {
94
-                return $rdn->toASN1();
95
-            }, $this->_rdns);
96
-        return new Sequence(...$elements);
97
-    }
85
+	/**
86
+	 * Generate ASN.1 structure.
87
+	 *
88
+	 * @return Sequence
89
+	 */
90
+	public function toASN1(): Sequence
91
+	{
92
+		$elements = array_map(
93
+			function (RDN $rdn) {
94
+				return $rdn->toASN1();
95
+			}, $this->_rdns);
96
+		return new Sequence(...$elements);
97
+	}
98 98
     
99
-    /**
100
-     * Get distinguised name string conforming to RFC 2253.
101
-     *
102
-     * @link https://tools.ietf.org/html/rfc2253#section-2.1
103
-     * @return string
104
-     */
105
-    public function toString(): string
106
-    {
107
-        $parts = array_map(
108
-            function (RDN $rdn) {
109
-                return $rdn->toString();
110
-            }, array_reverse($this->_rdns));
111
-        return implode(",", $parts);
112
-    }
99
+	/**
100
+	 * Get distinguised name string conforming to RFC 2253.
101
+	 *
102
+	 * @link https://tools.ietf.org/html/rfc2253#section-2.1
103
+	 * @return string
104
+	 */
105
+	public function toString(): string
106
+	{
107
+		$parts = array_map(
108
+			function (RDN $rdn) {
109
+				return $rdn->toString();
110
+			}, array_reverse($this->_rdns));
111
+		return implode(",", $parts);
112
+	}
113 113
     
114
-    /**
115
-     * Whether name is semantically equal to other.
116
-     * Comparison conforms to RFC 4518 string preparation algorithm.
117
-     *
118
-     * @link https://tools.ietf.org/html/rfc4518
119
-     * @param Name $other Object to compare to
120
-     * @return bool
121
-     */
122
-    public function equals(Name $other): bool
123
-    {
124
-        // if RDN count doesn't match
125
-        if (count($this) != count($other)) {
126
-            return false;
127
-        }
128
-        for ($i = count($this) - 1; $i >= 0; --$i) {
129
-            $rdn1 = $this->_rdns[$i];
130
-            $rdn2 = $other->_rdns[$i];
131
-            if (!$rdn1->equals($rdn2)) {
132
-                return false;
133
-            }
134
-        }
135
-        return true;
136
-    }
114
+	/**
115
+	 * Whether name is semantically equal to other.
116
+	 * Comparison conforms to RFC 4518 string preparation algorithm.
117
+	 *
118
+	 * @link https://tools.ietf.org/html/rfc4518
119
+	 * @param Name $other Object to compare to
120
+	 * @return bool
121
+	 */
122
+	public function equals(Name $other): bool
123
+	{
124
+		// if RDN count doesn't match
125
+		if (count($this) != count($other)) {
126
+			return false;
127
+		}
128
+		for ($i = count($this) - 1; $i >= 0; --$i) {
129
+			$rdn1 = $this->_rdns[$i];
130
+			$rdn2 = $other->_rdns[$i];
131
+			if (!$rdn1->equals($rdn2)) {
132
+				return false;
133
+			}
134
+		}
135
+		return true;
136
+	}
137 137
     
138
-    /**
139
-     * Get all RDN objects.
140
-     *
141
-     * @return RDN[]
142
-     */
143
-    public function all(): array
144
-    {
145
-        return $this->_rdns;
146
-    }
138
+	/**
139
+	 * Get all RDN objects.
140
+	 *
141
+	 * @return RDN[]
142
+	 */
143
+	public function all(): array
144
+	{
145
+		return $this->_rdns;
146
+	}
147 147
     
148
-    /**
149
-     * Get the first AttributeValue of given type.
150
-     *
151
-     * Relative name components shall be traversed in encoding order, which is
152
-     * reversed in regards to the string representation.
153
-     * Multi-valued RDN with multiple attributes of the requested type is
154
-     * ambiguous and shall throw an exception.
155
-     *
156
-     * @param string $name Attribute OID or name
157
-     * @throws \RuntimeException If attribute cannot be resolved
158
-     * @return AttributeValue
159
-     */
160
-    public function firstValueOf(string $name): AttributeValue
161
-    {
162
-        $oid = AttributeType::attrNameToOID($name);
163
-        foreach ($this->_rdns as $rdn) {
164
-            $tvs = $rdn->allOf($oid);
165
-            if (count($tvs) > 1) {
166
-                throw new \RangeException("RDN with multiple $name attributes.");
167
-            }
168
-            if (1 == count($tvs)) {
169
-                return $tvs[0]->value();
170
-            }
171
-        }
172
-        throw new \RangeException("Attribute $name not found.");
173
-    }
148
+	/**
149
+	 * Get the first AttributeValue of given type.
150
+	 *
151
+	 * Relative name components shall be traversed in encoding order, which is
152
+	 * reversed in regards to the string representation.
153
+	 * Multi-valued RDN with multiple attributes of the requested type is
154
+	 * ambiguous and shall throw an exception.
155
+	 *
156
+	 * @param string $name Attribute OID or name
157
+	 * @throws \RuntimeException If attribute cannot be resolved
158
+	 * @return AttributeValue
159
+	 */
160
+	public function firstValueOf(string $name): AttributeValue
161
+	{
162
+		$oid = AttributeType::attrNameToOID($name);
163
+		foreach ($this->_rdns as $rdn) {
164
+			$tvs = $rdn->allOf($oid);
165
+			if (count($tvs) > 1) {
166
+				throw new \RangeException("RDN with multiple $name attributes.");
167
+			}
168
+			if (1 == count($tvs)) {
169
+				return $tvs[0]->value();
170
+			}
171
+		}
172
+		throw new \RangeException("Attribute $name not found.");
173
+	}
174 174
     
175
-    /**
176
-     *
177
-     * @see \Countable::count()
178
-     * @return int
179
-     */
180
-    public function count(): int
181
-    {
182
-        return count($this->_rdns);
183
-    }
175
+	/**
176
+	 *
177
+	 * @see \Countable::count()
178
+	 * @return int
179
+	 */
180
+	public function count(): int
181
+	{
182
+		return count($this->_rdns);
183
+	}
184 184
     
185
-    /**
186
-     * Get the number of attributes of given type.
187
-     *
188
-     * @param string $name Attribute OID or name
189
-     * @return int
190
-     */
191
-    public function countOfType(string $name): int
192
-    {
193
-        $oid = AttributeType::attrNameToOID($name);
194
-        return array_sum(
195
-            array_map(
196
-                function (RDN $rdn) use ($oid) {
197
-                    return count($rdn->allOf($oid));
198
-                }, $this->_rdns));
199
-    }
185
+	/**
186
+	 * Get the number of attributes of given type.
187
+	 *
188
+	 * @param string $name Attribute OID or name
189
+	 * @return int
190
+	 */
191
+	public function countOfType(string $name): int
192
+	{
193
+		$oid = AttributeType::attrNameToOID($name);
194
+		return array_sum(
195
+			array_map(
196
+				function (RDN $rdn) use ($oid) {
197
+					return count($rdn->allOf($oid));
198
+				}, $this->_rdns));
199
+	}
200 200
     
201
-    /**
202
-     *
203
-     * @see \IteratorAggregate::getIterator()
204
-     * @return \ArrayIterator
205
-     */
206
-    public function getIterator(): \ArrayIterator
207
-    {
208
-        return new \ArrayIterator($this->_rdns);
209
-    }
201
+	/**
202
+	 *
203
+	 * @see \IteratorAggregate::getIterator()
204
+	 * @return \ArrayIterator
205
+	 */
206
+	public function getIterator(): \ArrayIterator
207
+	{
208
+		return new \ArrayIterator($this->_rdns);
209
+	}
210 210
     
211
-    /**
212
-     *
213
-     * @return string
214
-     */
215
-    public function __toString()
216
-    {
217
-        return $this->toString();
218
-    }
211
+	/**
212
+	 *
213
+	 * @return string
214
+	 */
215
+	public function __toString()
216
+	{
217
+		return $this->toString();
218
+	}
219 219
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     public static function fromASN1(Sequence $seq): self
48 48
     {
49 49
         $rdns = array_map(
50
-            function (UnspecifiedType $el) {
50
+            function(UnspecifiedType $el) {
51 51
                 return RDN::fromASN1($el->asSet());
52 52
             }, $seq->elements());
53 53
         return new self(...$rdns);
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     public function toASN1(): Sequence
91 91
     {
92 92
         $elements = array_map(
93
-            function (RDN $rdn) {
93
+            function(RDN $rdn) {
94 94
                 return $rdn->toASN1();
95 95
             }, $this->_rdns);
96 96
         return new Sequence(...$elements);
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     public function toString(): string
106 106
     {
107 107
         $parts = array_map(
108
-            function (RDN $rdn) {
108
+            function(RDN $rdn) {
109 109
                 return $rdn->toString();
110 110
             }, array_reverse($this->_rdns));
111 111
         return implode(",", $parts);
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
         $oid = AttributeType::attrNameToOID($name);
194 194
         return array_sum(
195 195
             array_map(
196
-                function (RDN $rdn) use ($oid) {
196
+                function(RDN $rdn) use ($oid) {
197 197
                     return count($rdn->allOf($oid));
198 198
                 }, $this->_rdns));
199 199
     }
Please login to merge, or discard this patch.
lib/X501/ASN1/AttributeTypeAndValue.php 1 patch
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -16,111 +16,111 @@
 block discarded – undo
16 16
  */
17 17
 class AttributeTypeAndValue
18 18
 {
19
-    use TypedAttribute;
19
+	use TypedAttribute;
20 20
     
21
-    /**
22
-     * Attribute value.
23
-     *
24
-     * @var AttributeValue $_value
25
-     */
26
-    protected $_value;
21
+	/**
22
+	 * Attribute value.
23
+	 *
24
+	 * @var AttributeValue $_value
25
+	 */
26
+	protected $_value;
27 27
     
28
-    /**
29
-     * Constructor.
30
-     *
31
-     * @param AttributeType $type Attribute type
32
-     * @param AttributeValue $value Attribute value
33
-     */
34
-    public function __construct(AttributeType $type, AttributeValue $value)
35
-    {
36
-        $this->_type = $type;
37
-        $this->_value = $value;
38
-    }
28
+	/**
29
+	 * Constructor.
30
+	 *
31
+	 * @param AttributeType $type Attribute type
32
+	 * @param AttributeValue $value Attribute value
33
+	 */
34
+	public function __construct(AttributeType $type, AttributeValue $value)
35
+	{
36
+		$this->_type = $type;
37
+		$this->_value = $value;
38
+	}
39 39
     
40
-    /**
41
-     * Initialize from ASN.1.
42
-     *
43
-     * @param Sequence $seq
44
-     * @return self
45
-     */
46
-    public static function fromASN1(Sequence $seq): self
47
-    {
48
-        $type = AttributeType::fromASN1($seq->at(0)->asObjectIdentifier());
49
-        $value = AttributeValue::fromASN1ByOID($type->oid(), $seq->at(1));
50
-        return new self($type, $value);
51
-    }
40
+	/**
41
+	 * Initialize from ASN.1.
42
+	 *
43
+	 * @param Sequence $seq
44
+	 * @return self
45
+	 */
46
+	public static function fromASN1(Sequence $seq): self
47
+	{
48
+		$type = AttributeType::fromASN1($seq->at(0)->asObjectIdentifier());
49
+		$value = AttributeValue::fromASN1ByOID($type->oid(), $seq->at(1));
50
+		return new self($type, $value);
51
+	}
52 52
     
53
-    /**
54
-     * Convenience method to initialize from attribute value.
55
-     *
56
-     * @param AttributeValue $value Attribute value
57
-     * @return self
58
-     */
59
-    public static function fromAttributeValue(AttributeValue $value): self
60
-    {
61
-        return new self(new AttributeType($value->oid()), $value);
62
-    }
53
+	/**
54
+	 * Convenience method to initialize from attribute value.
55
+	 *
56
+	 * @param AttributeValue $value Attribute value
57
+	 * @return self
58
+	 */
59
+	public static function fromAttributeValue(AttributeValue $value): self
60
+	{
61
+		return new self(new AttributeType($value->oid()), $value);
62
+	}
63 63
     
64
-    /**
65
-     * Get attribute value.
66
-     *
67
-     * @return AttributeValue
68
-     */
69
-    public function value(): AttributeValue
70
-    {
71
-        return $this->_value;
72
-    }
64
+	/**
65
+	 * Get attribute value.
66
+	 *
67
+	 * @return AttributeValue
68
+	 */
69
+	public function value(): AttributeValue
70
+	{
71
+		return $this->_value;
72
+	}
73 73
     
74
-    /**
75
-     * Generate ASN.1 structure.
76
-     *
77
-     * @return Sequence
78
-     */
79
-    public function toASN1(): Sequence
80
-    {
81
-        return new Sequence($this->_type->toASN1(), $this->_value->toASN1());
82
-    }
74
+	/**
75
+	 * Generate ASN.1 structure.
76
+	 *
77
+	 * @return Sequence
78
+	 */
79
+	public function toASN1(): Sequence
80
+	{
81
+		return new Sequence($this->_type->toASN1(), $this->_value->toASN1());
82
+	}
83 83
     
84
-    /**
85
-     * Get attributeTypeAndValue string conforming to RFC 2253.
86
-     *
87
-     * @link https://tools.ietf.org/html/rfc2253#section-2.3
88
-     * @return string
89
-     */
90
-    public function toString(): string
91
-    {
92
-        return $this->_type->typeName() . "=" . $this->_value->rfc2253String();
93
-    }
84
+	/**
85
+	 * Get attributeTypeAndValue string conforming to RFC 2253.
86
+	 *
87
+	 * @link https://tools.ietf.org/html/rfc2253#section-2.3
88
+	 * @return string
89
+	 */
90
+	public function toString(): string
91
+	{
92
+		return $this->_type->typeName() . "=" . $this->_value->rfc2253String();
93
+	}
94 94
     
95
-    /**
96
-     * Check whether attribute is semantically equal to other.
97
-     *
98
-     * @param AttributeTypeAndValue $other Object to compare to
99
-     * @return bool
100
-     */
101
-    public function equals(AttributeTypeAndValue $other): bool
102
-    {
103
-        // check that attribute types match
104
-        if ($this->oid() !== $other->oid()) {
105
-            return false;
106
-        }
107
-        $matcher = $this->_value->equalityMatchingRule();
108
-        $result = $matcher->compare($this->_value->stringValue(),
109
-            $other->_value->stringValue());
110
-        // match
111
-        if ($result) {
112
-            return true;
113
-        }
114
-        // no match or Undefined
115
-        return false;
116
-    }
95
+	/**
96
+	 * Check whether attribute is semantically equal to other.
97
+	 *
98
+	 * @param AttributeTypeAndValue $other Object to compare to
99
+	 * @return bool
100
+	 */
101
+	public function equals(AttributeTypeAndValue $other): bool
102
+	{
103
+		// check that attribute types match
104
+		if ($this->oid() !== $other->oid()) {
105
+			return false;
106
+		}
107
+		$matcher = $this->_value->equalityMatchingRule();
108
+		$result = $matcher->compare($this->_value->stringValue(),
109
+			$other->_value->stringValue());
110
+		// match
111
+		if ($result) {
112
+			return true;
113
+		}
114
+		// no match or Undefined
115
+		return false;
116
+	}
117 117
     
118
-    /**
119
-     *
120
-     * @return string
121
-     */
122
-    public function __toString()
123
-    {
124
-        return $this->toString();
125
-    }
118
+	/**
119
+	 *
120
+	 * @return string
121
+	 */
122
+	public function __toString()
123
+	{
124
+		return $this->toString();
125
+	}
126 126
 }
Please login to merge, or discard this patch.
lib/X501/ASN1/RDN.php 2 patches
Indentation   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -16,169 +16,169 @@
 block discarded – undo
16 16
  */
17 17
 class RDN implements \Countable, \IteratorAggregate
18 18
 {
19
-    /**
20
-     * Attributes.
21
-     *
22
-     * @var AttributeTypeAndValue[] $_attribs
23
-     */
24
-    protected $_attribs;
19
+	/**
20
+	 * Attributes.
21
+	 *
22
+	 * @var AttributeTypeAndValue[] $_attribs
23
+	 */
24
+	protected $_attribs;
25 25
     
26
-    /**
27
-     * Constructor.
28
-     *
29
-     * @param AttributeTypeAndValue ...$attribs One or more attributes
30
-     */
31
-    public function __construct(AttributeTypeAndValue ...$attribs)
32
-    {
33
-        if (!count($attribs)) {
34
-            throw new \UnexpectedValueException(
35
-                "RDN must have at least one AttributeTypeAndValue.");
36
-        }
37
-        $this->_attribs = $attribs;
38
-    }
26
+	/**
27
+	 * Constructor.
28
+	 *
29
+	 * @param AttributeTypeAndValue ...$attribs One or more attributes
30
+	 */
31
+	public function __construct(AttributeTypeAndValue ...$attribs)
32
+	{
33
+		if (!count($attribs)) {
34
+			throw new \UnexpectedValueException(
35
+				"RDN must have at least one AttributeTypeAndValue.");
36
+		}
37
+		$this->_attribs = $attribs;
38
+	}
39 39
     
40
-    /**
41
-     * Convenience method to initialize RDN from AttributeValue objects.
42
-     *
43
-     * @param AttributeValue ...$values One or more attributes
44
-     * @return self
45
-     */
46
-    public static function fromAttributeValues(AttributeValue ...$values): self
47
-    {
48
-        $attribs = array_map(
49
-            function (AttributeValue $value) {
50
-                return new AttributeTypeAndValue(
51
-                    new AttributeType($value->oid()), $value);
52
-            }, $values);
53
-        return new self(...$attribs);
54
-    }
40
+	/**
41
+	 * Convenience method to initialize RDN from AttributeValue objects.
42
+	 *
43
+	 * @param AttributeValue ...$values One or more attributes
44
+	 * @return self
45
+	 */
46
+	public static function fromAttributeValues(AttributeValue ...$values): self
47
+	{
48
+		$attribs = array_map(
49
+			function (AttributeValue $value) {
50
+				return new AttributeTypeAndValue(
51
+					new AttributeType($value->oid()), $value);
52
+			}, $values);
53
+		return new self(...$attribs);
54
+	}
55 55
     
56
-    /**
57
-     * Initialize from ASN.1.
58
-     *
59
-     * @param Set $set
60
-     * @return self
61
-     */
62
-    public static function fromASN1(Set $set): self
63
-    {
64
-        $attribs = array_map(
65
-            function (UnspecifiedType $el) {
66
-                return AttributeTypeAndValue::fromASN1($el->asSequence());
67
-            }, $set->elements());
68
-        return new self(...$attribs);
69
-    }
56
+	/**
57
+	 * Initialize from ASN.1.
58
+	 *
59
+	 * @param Set $set
60
+	 * @return self
61
+	 */
62
+	public static function fromASN1(Set $set): self
63
+	{
64
+		$attribs = array_map(
65
+			function (UnspecifiedType $el) {
66
+				return AttributeTypeAndValue::fromASN1($el->asSequence());
67
+			}, $set->elements());
68
+		return new self(...$attribs);
69
+	}
70 70
     
71
-    /**
72
-     * Generate ASN.1 structure.
73
-     *
74
-     * @return Set
75
-     */
76
-    public function toASN1(): Set
77
-    {
78
-        $elements = array_map(
79
-            function (AttributeTypeAndValue $tv) {
80
-                return $tv->toASN1();
81
-            }, $this->_attribs);
82
-        $set = new Set(...$elements);
83
-        return $set->sortedSetOf();
84
-    }
71
+	/**
72
+	 * Generate ASN.1 structure.
73
+	 *
74
+	 * @return Set
75
+	 */
76
+	public function toASN1(): Set
77
+	{
78
+		$elements = array_map(
79
+			function (AttributeTypeAndValue $tv) {
80
+				return $tv->toASN1();
81
+			}, $this->_attribs);
82
+		$set = new Set(...$elements);
83
+		return $set->sortedSetOf();
84
+	}
85 85
     
86
-    /**
87
-     * Get name-component string conforming to RFC 2253.
88
-     *
89
-     * @link https://tools.ietf.org/html/rfc2253#section-2.2
90
-     * @return string
91
-     */
92
-    public function toString(): string
93
-    {
94
-        $parts = array_map(
95
-            function (AttributeTypeAndValue $tv) {
96
-                return $tv->toString();
97
-            }, $this->_attribs);
98
-        return implode("+", $parts);
99
-    }
86
+	/**
87
+	 * Get name-component string conforming to RFC 2253.
88
+	 *
89
+	 * @link https://tools.ietf.org/html/rfc2253#section-2.2
90
+	 * @return string
91
+	 */
92
+	public function toString(): string
93
+	{
94
+		$parts = array_map(
95
+			function (AttributeTypeAndValue $tv) {
96
+				return $tv->toString();
97
+			}, $this->_attribs);
98
+		return implode("+", $parts);
99
+	}
100 100
     
101
-    /**
102
-     * Check whether RDN is semantically equal to other.
103
-     *
104
-     * @param RDN $other Object to compare to
105
-     * @return bool
106
-     */
107
-    public function equals(RDN $other): bool
108
-    {
109
-        // if attribute count doesn't match
110
-        if (count($this) != count($other)) {
111
-            return false;
112
-        }
113
-        $attribs1 = $this->_attribs;
114
-        $attribs2 = $other->_attribs;
115
-        // if there's multiple attributes, sort using SET OF rules
116
-        if (count($attribs1) > 1) {
117
-            $attribs1 = self::fromASN1($this->toASN1())->_attribs;
118
-            $attribs2 = self::fromASN1($other->toASN1())->_attribs;
119
-        }
120
-        for ($i = count($attribs1) - 1; $i >= 0; --$i) {
121
-            $tv1 = $attribs1[$i];
122
-            $tv2 = $attribs2[$i];
123
-            if (!$tv1->equals($tv2)) {
124
-                return false;
125
-            }
126
-        }
127
-        return true;
128
-    }
101
+	/**
102
+	 * Check whether RDN is semantically equal to other.
103
+	 *
104
+	 * @param RDN $other Object to compare to
105
+	 * @return bool
106
+	 */
107
+	public function equals(RDN $other): bool
108
+	{
109
+		// if attribute count doesn't match
110
+		if (count($this) != count($other)) {
111
+			return false;
112
+		}
113
+		$attribs1 = $this->_attribs;
114
+		$attribs2 = $other->_attribs;
115
+		// if there's multiple attributes, sort using SET OF rules
116
+		if (count($attribs1) > 1) {
117
+			$attribs1 = self::fromASN1($this->toASN1())->_attribs;
118
+			$attribs2 = self::fromASN1($other->toASN1())->_attribs;
119
+		}
120
+		for ($i = count($attribs1) - 1; $i >= 0; --$i) {
121
+			$tv1 = $attribs1[$i];
122
+			$tv2 = $attribs2[$i];
123
+			if (!$tv1->equals($tv2)) {
124
+				return false;
125
+			}
126
+		}
127
+		return true;
128
+	}
129 129
     
130
-    /**
131
-     * Get all AttributeTypeAndValue objects.
132
-     *
133
-     * @return AttributeTypeAndValue[]
134
-     */
135
-    public function all(): array
136
-    {
137
-        return $this->_attribs;
138
-    }
130
+	/**
131
+	 * Get all AttributeTypeAndValue objects.
132
+	 *
133
+	 * @return AttributeTypeAndValue[]
134
+	 */
135
+	public function all(): array
136
+	{
137
+		return $this->_attribs;
138
+	}
139 139
     
140
-    /**
141
-     * Get all AttributeTypeAndValue objects of the given attribute type.
142
-     *
143
-     * @param string $name Attribute OID or name
144
-     * @return AttributeTypeAndValue[]
145
-     */
146
-    public function allOf(string $name): array
147
-    {
148
-        $oid = AttributeType::attrNameToOID($name);
149
-        $attribs = array_filter($this->_attribs,
150
-            function (AttributeTypeAndValue $tv) use ($oid) {
151
-                return $tv->oid() == $oid;
152
-            });
153
-        return array_values($attribs);
154
-    }
140
+	/**
141
+	 * Get all AttributeTypeAndValue objects of the given attribute type.
142
+	 *
143
+	 * @param string $name Attribute OID or name
144
+	 * @return AttributeTypeAndValue[]
145
+	 */
146
+	public function allOf(string $name): array
147
+	{
148
+		$oid = AttributeType::attrNameToOID($name);
149
+		$attribs = array_filter($this->_attribs,
150
+			function (AttributeTypeAndValue $tv) use ($oid) {
151
+				return $tv->oid() == $oid;
152
+			});
153
+		return array_values($attribs);
154
+	}
155 155
     
156
-    /**
157
-     *
158
-     * @see \Countable::count()
159
-     * @return int
160
-     */
161
-    public function count(): int
162
-    {
163
-        return count($this->_attribs);
164
-    }
156
+	/**
157
+	 *
158
+	 * @see \Countable::count()
159
+	 * @return int
160
+	 */
161
+	public function count(): int
162
+	{
163
+		return count($this->_attribs);
164
+	}
165 165
     
166
-    /**
167
-     *
168
-     * @see \IteratorAggregate::getIterator()
169
-     * @return \ArrayIterator
170
-     */
171
-    public function getIterator(): \ArrayIterator
172
-    {
173
-        return new \ArrayIterator($this->_attribs);
174
-    }
166
+	/**
167
+	 *
168
+	 * @see \IteratorAggregate::getIterator()
169
+	 * @return \ArrayIterator
170
+	 */
171
+	public function getIterator(): \ArrayIterator
172
+	{
173
+		return new \ArrayIterator($this->_attribs);
174
+	}
175 175
     
176
-    /**
177
-     *
178
-     * @return string
179
-     */
180
-    public function __toString()
181
-    {
182
-        return $this->toString();
183
-    }
176
+	/**
177
+	 *
178
+	 * @return string
179
+	 */
180
+	public function __toString()
181
+	{
182
+		return $this->toString();
183
+	}
184 184
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
     public static function fromAttributeValues(AttributeValue ...$values): self
47 47
     {
48 48
         $attribs = array_map(
49
-            function (AttributeValue $value) {
49
+            function(AttributeValue $value) {
50 50
                 return new AttributeTypeAndValue(
51 51
                     new AttributeType($value->oid()), $value);
52 52
             }, $values);
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     public static function fromASN1(Set $set): self
63 63
     {
64 64
         $attribs = array_map(
65
-            function (UnspecifiedType $el) {
65
+            function(UnspecifiedType $el) {
66 66
                 return AttributeTypeAndValue::fromASN1($el->asSequence());
67 67
             }, $set->elements());
68 68
         return new self(...$attribs);
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     public function toASN1(): Set
77 77
     {
78 78
         $elements = array_map(
79
-            function (AttributeTypeAndValue $tv) {
79
+            function(AttributeTypeAndValue $tv) {
80 80
                 return $tv->toASN1();
81 81
             }, $this->_attribs);
82 82
         $set = new Set(...$elements);
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     public function toString(): string
93 93
     {
94 94
         $parts = array_map(
95
-            function (AttributeTypeAndValue $tv) {
95
+            function(AttributeTypeAndValue $tv) {
96 96
                 return $tv->toString();
97 97
             }, $this->_attribs);
98 98
         return implode("+", $parts);
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     {
148 148
         $oid = AttributeType::attrNameToOID($name);
149 149
         $attribs = array_filter($this->_attribs,
150
-            function (AttributeTypeAndValue $tv) use ($oid) {
150
+            function(AttributeTypeAndValue $tv) use ($oid) {
151 151
                 return $tv->oid() == $oid;
152 152
             });
153 153
         return array_values($attribs);
Please login to merge, or discard this patch.
lib/X501/ASN1/AttributeValue/OrganizationalUnitNameValue.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -15,16 +15,16 @@
 block discarded – undo
15 15
  */
16 16
 class OrganizationalUnitNameValue extends DirectoryString
17 17
 {
18
-    /**
19
-     * Constructor.
20
-     *
21
-     * @param string $value String value
22
-     * @param int $string_tag Syntax choice
23
-     */
24
-    public function __construct(string $value,
25
-        int $string_tag = DirectoryString::UTF8)
26
-    {
27
-        $this->_oid = AttributeType::OID_ORGANIZATIONAL_UNIT_NAME;
28
-        parent::__construct($value, $string_tag);
29
-    }
18
+	/**
19
+	 * Constructor.
20
+	 *
21
+	 * @param string $value String value
22
+	 * @param int $string_tag Syntax choice
23
+	 */
24
+	public function __construct(string $value,
25
+		int $string_tag = DirectoryString::UTF8)
26
+	{
27
+		$this->_oid = AttributeType::OID_ORGANIZATIONAL_UNIT_NAME;
28
+		parent::__construct($value, $string_tag);
29
+	}
30 30
 }
Please login to merge, or discard this patch.
lib/X501/ASN1/AttributeValue/GivenNameValue.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -15,16 +15,16 @@
 block discarded – undo
15 15
  */
16 16
 class GivenNameValue extends DirectoryString
17 17
 {
18
-    /**
19
-     * Constructor.
20
-     *
21
-     * @param string $value String value
22
-     * @param int $string_tag Syntax choice
23
-     */
24
-    public function __construct(string $value,
25
-        int $string_tag = DirectoryString::UTF8)
26
-    {
27
-        $this->_oid = AttributeType::OID_GIVEN_NAME;
28
-        parent::__construct($value, $string_tag);
29
-    }
18
+	/**
19
+	 * Constructor.
20
+	 *
21
+	 * @param string $value String value
22
+	 * @param int $string_tag Syntax choice
23
+	 */
24
+	public function __construct(string $value,
25
+		int $string_tag = DirectoryString::UTF8)
26
+	{
27
+		$this->_oid = AttributeType::OID_GIVEN_NAME;
28
+		parent::__construct($value, $string_tag);
29
+	}
30 30
 }
Please login to merge, or discard this patch.
lib/X501/ASN1/AttributeValue/SerialNumberValue.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -15,14 +15,14 @@
 block discarded – undo
15 15
  */
16 16
 class SerialNumberValue extends PrintableStringValue
17 17
 {
18
-    /**
19
-     * Constructor.
20
-     *
21
-     * @param string $value String value
22
-     */
23
-    public function __construct(string $value)
24
-    {
25
-        $this->_oid = AttributeType::OID_SERIAL_NUMBER;
26
-        parent::__construct($value);
27
-    }
18
+	/**
19
+	 * Constructor.
20
+	 *
21
+	 * @param string $value String value
22
+	 */
23
+	public function __construct(string $value)
24
+	{
25
+		$this->_oid = AttributeType::OID_SERIAL_NUMBER;
26
+		parent::__construct($value);
27
+	}
28 28
 }
Please login to merge, or discard this patch.