GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Failed
Push — master ( 405cf3...79c9ba )
by Joni
04:48
created
lib/X509/AttributeCertificate/Attribute/ChargingIdentityAttributeValue.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,16 +11,16 @@
 block discarded – undo
11 11
  */
12 12
 class ChargingIdentityAttributeValue extends IetfAttrSyntax
13 13
 {
14
-    const OID = '1.3.6.1.5.5.7.10.3';
14
+	const OID = '1.3.6.1.5.5.7.10.3';
15 15
 
16
-    /**
17
-     * Constructor.
18
-     *
19
-     * @param IetfAttrValue ...$values
20
-     */
21
-    public function __construct(IetfAttrValue ...$values)
22
-    {
23
-        parent::__construct(...$values);
24
-        $this->_oid = self::OID;
25
-    }
16
+	/**
17
+	 * Constructor.
18
+	 *
19
+	 * @param IetfAttrValue ...$values
20
+	 */
21
+	public function __construct(IetfAttrValue ...$values)
22
+	{
23
+		parent::__construct(...$values);
24
+		$this->_oid = self::OID;
25
+	}
26 26
 }
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\X509\AttributeCertificate\Attribute;
6 6
 
Please login to merge, or discard this patch.
lib/X509/AttributeCertificate/Attributes.php 2 patches
Indentation   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -26,200 +26,200 @@
 block discarded – undo
26 26
  */
27 27
 class Attributes implements \Countable, \IteratorAggregate
28 28
 {
29
-    use AttributeContainer;
30
-
31
-    /**
32
-     * Mapping from OID to attribute value class name.
33
-     *
34
-     * @internal
35
-     *
36
-     * @var array
37
-     */
38
-    const MAP_OID_TO_CLASS = [
39
-        AccessIdentityAttributeValue::OID => AccessIdentityAttributeValue::class,
40
-        AuthenticationInfoAttributeValue::OID => AuthenticationInfoAttributeValue::class,
41
-        ChargingIdentityAttributeValue::OID => ChargingIdentityAttributeValue::class,
42
-        GroupAttributeValue::OID => GroupAttributeValue::class,
43
-        AttributeType::OID_ROLE => RoleAttributeValue::class,
44
-    ];
45
-
46
-    /**
47
-     * Constructor.
48
-     *
49
-     * @param Attribute ...$attribs
50
-     */
51
-    public function __construct(Attribute ...$attribs)
52
-    {
53
-        $this->_attributes = $attribs;
54
-    }
55
-
56
-    /**
57
-     * Initialize from attribute values.
58
-     *
59
-     * @param AttributeValue ...$values
60
-     *
61
-     * @return self
62
-     */
63
-    public static function fromAttributeValues(AttributeValue ...$values): self
64
-    {
65
-        $attribs = array_map(
66
-            function (AttributeValue $value) {
67
-                return $value->toAttribute();
68
-            }, $values);
69
-        return new self(...$attribs);
70
-    }
71
-
72
-    /**
73
-     * Initialize from ASN.1.
74
-     *
75
-     * @param Sequence $seq
76
-     *
77
-     * @return self
78
-     */
79
-    public static function fromASN1(Sequence $seq): self
80
-    {
81
-        $attribs = array_map(
82
-            function (UnspecifiedType $el) {
83
-                return Attribute::fromASN1($el->asSequence());
84
-            }, $seq->elements());
85
-        // cast attributes
86
-        $attribs = array_map(
87
-            function (Attribute $attr) {
88
-                $oid = $attr->oid();
89
-                if (array_key_exists($oid, self::MAP_OID_TO_CLASS)) {
90
-                    $cls = self::MAP_OID_TO_CLASS[$oid];
91
-                    $attr = $attr->castValues($cls);
92
-                }
93
-                return $attr;
94
-            }, $attribs);
95
-        return new self(...$attribs);
96
-    }
97
-
98
-    /**
99
-     * Check whether 'Access Identity' attribute is present.
100
-     *
101
-     * @return bool
102
-     */
103
-    public function hasAccessIdentity(): bool
104
-    {
105
-        return $this->has(AccessIdentityAttributeValue::OID);
106
-    }
107
-
108
-    /**
109
-     * Get the first 'Access Identity' attribute value.
110
-     *
111
-     * @return AccessIdentityAttributeValue
112
-     */
113
-    public function accessIdentity(): AccessIdentityAttributeValue
114
-    {
115
-        return $this->firstOf(AccessIdentityAttributeValue::OID)->first();
116
-    }
117
-
118
-    /**
119
-     * Check whether 'Service Authentication Information' attribute is present.
120
-     *
121
-     * @return bool
122
-     */
123
-    public function hasAuthenticationInformation(): bool
124
-    {
125
-        return $this->has(AuthenticationInfoAttributeValue::OID);
126
-    }
127
-
128
-    /**
129
-     * Get the first 'Service Authentication Information' attribute value.
130
-     *
131
-     * @return AuthenticationInfoAttributeValue
132
-     */
133
-    public function authenticationInformation(): AuthenticationInfoAttributeValue
134
-    {
135
-        return $this->firstOf(AuthenticationInfoAttributeValue::OID)->first();
136
-    }
137
-
138
-    /**
139
-     * Check whether 'Charging Identity' attribute is present.
140
-     *
141
-     * @return bool
142
-     */
143
-    public function hasChargingIdentity(): bool
144
-    {
145
-        return $this->has(ChargingIdentityAttributeValue::OID);
146
-    }
147
-
148
-    /**
149
-     * Get the first 'Charging Identity' attribute value.
150
-     *
151
-     * @return ChargingIdentityAttributeValue
152
-     */
153
-    public function chargingIdentity(): ChargingIdentityAttributeValue
154
-    {
155
-        return $this->firstOf(ChargingIdentityAttributeValue::OID)->first();
156
-    }
157
-
158
-    /**
159
-     * Check whether 'Group' attribute is present.
160
-     *
161
-     * @return bool
162
-     */
163
-    public function hasGroup(): bool
164
-    {
165
-        return $this->has(GroupAttributeValue::OID);
166
-    }
167
-
168
-    /**
169
-     * Get the first 'Group' attribute value.
170
-     *
171
-     * @return GroupAttributeValue
172
-     */
173
-    public function group(): GroupAttributeValue
174
-    {
175
-        return $this->firstOf(GroupAttributeValue::OID)->first();
176
-    }
177
-
178
-    /**
179
-     * Check whether 'Role' attribute is present.
180
-     *
181
-     * @return bool
182
-     */
183
-    public function hasRole(): bool
184
-    {
185
-        return $this->has(AttributeType::OID_ROLE);
186
-    }
187
-
188
-    /**
189
-     * Get the first 'Role' attribute value.
190
-     *
191
-     * @return RoleAttributeValue
192
-     */
193
-    public function role(): RoleAttributeValue
194
-    {
195
-        return $this->firstOf(AttributeType::OID_ROLE)->first();
196
-    }
197
-
198
-    /**
199
-     * Get all 'Role' attribute values.
200
-     *
201
-     * @return RoleAttributeValue[]
202
-     */
203
-    public function roles(): array
204
-    {
205
-        return array_merge([],
206
-            ...array_map(
207
-                function (Attribute $attr) {
208
-                    return $attr->values();
209
-                }, $this->allOf(AttributeType::OID_ROLE)));
210
-    }
211
-
212
-    /**
213
-     * Generate ASN.1 structure.
214
-     *
215
-     * @return Sequence
216
-     */
217
-    public function toASN1(): Sequence
218
-    {
219
-        $elements = array_map(
220
-            function (Attribute $attr) {
221
-                return $attr->toASN1();
222
-            }, array_values($this->_attributes));
223
-        return new Sequence(...$elements);
224
-    }
29
+	use AttributeContainer;
30
+
31
+	/**
32
+	 * Mapping from OID to attribute value class name.
33
+	 *
34
+	 * @internal
35
+	 *
36
+	 * @var array
37
+	 */
38
+	const MAP_OID_TO_CLASS = [
39
+		AccessIdentityAttributeValue::OID => AccessIdentityAttributeValue::class,
40
+		AuthenticationInfoAttributeValue::OID => AuthenticationInfoAttributeValue::class,
41
+		ChargingIdentityAttributeValue::OID => ChargingIdentityAttributeValue::class,
42
+		GroupAttributeValue::OID => GroupAttributeValue::class,
43
+		AttributeType::OID_ROLE => RoleAttributeValue::class,
44
+	];
45
+
46
+	/**
47
+	 * Constructor.
48
+	 *
49
+	 * @param Attribute ...$attribs
50
+	 */
51
+	public function __construct(Attribute ...$attribs)
52
+	{
53
+		$this->_attributes = $attribs;
54
+	}
55
+
56
+	/**
57
+	 * Initialize from attribute values.
58
+	 *
59
+	 * @param AttributeValue ...$values
60
+	 *
61
+	 * @return self
62
+	 */
63
+	public static function fromAttributeValues(AttributeValue ...$values): self
64
+	{
65
+		$attribs = array_map(
66
+			function (AttributeValue $value) {
67
+				return $value->toAttribute();
68
+			}, $values);
69
+		return new self(...$attribs);
70
+	}
71
+
72
+	/**
73
+	 * Initialize from ASN.1.
74
+	 *
75
+	 * @param Sequence $seq
76
+	 *
77
+	 * @return self
78
+	 */
79
+	public static function fromASN1(Sequence $seq): self
80
+	{
81
+		$attribs = array_map(
82
+			function (UnspecifiedType $el) {
83
+				return Attribute::fromASN1($el->asSequence());
84
+			}, $seq->elements());
85
+		// cast attributes
86
+		$attribs = array_map(
87
+			function (Attribute $attr) {
88
+				$oid = $attr->oid();
89
+				if (array_key_exists($oid, self::MAP_OID_TO_CLASS)) {
90
+					$cls = self::MAP_OID_TO_CLASS[$oid];
91
+					$attr = $attr->castValues($cls);
92
+				}
93
+				return $attr;
94
+			}, $attribs);
95
+		return new self(...$attribs);
96
+	}
97
+
98
+	/**
99
+	 * Check whether 'Access Identity' attribute is present.
100
+	 *
101
+	 * @return bool
102
+	 */
103
+	public function hasAccessIdentity(): bool
104
+	{
105
+		return $this->has(AccessIdentityAttributeValue::OID);
106
+	}
107
+
108
+	/**
109
+	 * Get the first 'Access Identity' attribute value.
110
+	 *
111
+	 * @return AccessIdentityAttributeValue
112
+	 */
113
+	public function accessIdentity(): AccessIdentityAttributeValue
114
+	{
115
+		return $this->firstOf(AccessIdentityAttributeValue::OID)->first();
116
+	}
117
+
118
+	/**
119
+	 * Check whether 'Service Authentication Information' attribute is present.
120
+	 *
121
+	 * @return bool
122
+	 */
123
+	public function hasAuthenticationInformation(): bool
124
+	{
125
+		return $this->has(AuthenticationInfoAttributeValue::OID);
126
+	}
127
+
128
+	/**
129
+	 * Get the first 'Service Authentication Information' attribute value.
130
+	 *
131
+	 * @return AuthenticationInfoAttributeValue
132
+	 */
133
+	public function authenticationInformation(): AuthenticationInfoAttributeValue
134
+	{
135
+		return $this->firstOf(AuthenticationInfoAttributeValue::OID)->first();
136
+	}
137
+
138
+	/**
139
+	 * Check whether 'Charging Identity' attribute is present.
140
+	 *
141
+	 * @return bool
142
+	 */
143
+	public function hasChargingIdentity(): bool
144
+	{
145
+		return $this->has(ChargingIdentityAttributeValue::OID);
146
+	}
147
+
148
+	/**
149
+	 * Get the first 'Charging Identity' attribute value.
150
+	 *
151
+	 * @return ChargingIdentityAttributeValue
152
+	 */
153
+	public function chargingIdentity(): ChargingIdentityAttributeValue
154
+	{
155
+		return $this->firstOf(ChargingIdentityAttributeValue::OID)->first();
156
+	}
157
+
158
+	/**
159
+	 * Check whether 'Group' attribute is present.
160
+	 *
161
+	 * @return bool
162
+	 */
163
+	public function hasGroup(): bool
164
+	{
165
+		return $this->has(GroupAttributeValue::OID);
166
+	}
167
+
168
+	/**
169
+	 * Get the first 'Group' attribute value.
170
+	 *
171
+	 * @return GroupAttributeValue
172
+	 */
173
+	public function group(): GroupAttributeValue
174
+	{
175
+		return $this->firstOf(GroupAttributeValue::OID)->first();
176
+	}
177
+
178
+	/**
179
+	 * Check whether 'Role' attribute is present.
180
+	 *
181
+	 * @return bool
182
+	 */
183
+	public function hasRole(): bool
184
+	{
185
+		return $this->has(AttributeType::OID_ROLE);
186
+	}
187
+
188
+	/**
189
+	 * Get the first 'Role' attribute value.
190
+	 *
191
+	 * @return RoleAttributeValue
192
+	 */
193
+	public function role(): RoleAttributeValue
194
+	{
195
+		return $this->firstOf(AttributeType::OID_ROLE)->first();
196
+	}
197
+
198
+	/**
199
+	 * Get all 'Role' attribute values.
200
+	 *
201
+	 * @return RoleAttributeValue[]
202
+	 */
203
+	public function roles(): array
204
+	{
205
+		return array_merge([],
206
+			...array_map(
207
+				function (Attribute $attr) {
208
+					return $attr->values();
209
+				}, $this->allOf(AttributeType::OID_ROLE)));
210
+	}
211
+
212
+	/**
213
+	 * Generate ASN.1 structure.
214
+	 *
215
+	 * @return Sequence
216
+	 */
217
+	public function toASN1(): Sequence
218
+	{
219
+		$elements = array_map(
220
+			function (Attribute $attr) {
221
+				return $attr->toASN1();
222
+			}, array_values($this->_attributes));
223
+		return new Sequence(...$elements);
224
+	}
225 225
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X509\AttributeCertificate;
6 6
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     public static function fromAttributeValues(AttributeValue ...$values): self
64 64
     {
65 65
         $attribs = array_map(
66
-            function (AttributeValue $value) {
66
+            function(AttributeValue $value) {
67 67
                 return $value->toAttribute();
68 68
             }, $values);
69 69
         return new self(...$attribs);
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
     public static function fromASN1(Sequence $seq): self
80 80
     {
81 81
         $attribs = array_map(
82
-            function (UnspecifiedType $el) {
82
+            function(UnspecifiedType $el) {
83 83
                 return Attribute::fromASN1($el->asSequence());
84 84
             }, $seq->elements());
85 85
         // cast attributes
86 86
         $attribs = array_map(
87
-            function (Attribute $attr) {
87
+            function(Attribute $attr) {
88 88
                 $oid = $attr->oid();
89 89
                 if (array_key_exists($oid, self::MAP_OID_TO_CLASS)) {
90 90
                     $cls = self::MAP_OID_TO_CLASS[$oid];
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
     {
205 205
         return array_merge([],
206 206
             ...array_map(
207
-                function (Attribute $attr) {
207
+                function(Attribute $attr) {
208 208
                     return $attr->values();
209 209
                 }, $this->allOf(AttributeType::OID_ROLE)));
210 210
     }
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
     public function toASN1(): Sequence
218 218
     {
219 219
         $elements = array_map(
220
-            function (Attribute $attr) {
220
+            function(Attribute $attr) {
221 221
                 return $attr->toASN1();
222 222
             }, array_values($this->_attributes));
223 223
         return new Sequence(...$elements);
Please login to merge, or discard this patch.
lib/X509/AttributeCertificate/ObjectDigestInfo.php 2 patches
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -20,89 +20,89 @@
 block discarded – undo
20 20
  */
21 21
 class ObjectDigestInfo
22 22
 {
23
-    const TYPE_PUBLIC_KEY = 0;
24
-    const TYPE_PUBLIC_KEY_CERT = 1;
25
-    const TYPE_OTHER_OBJECT_TYPES = 2;
23
+	const TYPE_PUBLIC_KEY = 0;
24
+	const TYPE_PUBLIC_KEY_CERT = 1;
25
+	const TYPE_OTHER_OBJECT_TYPES = 2;
26 26
 
27
-    /**
28
-     * Object type.
29
-     *
30
-     * @var int
31
-     */
32
-    protected $_digestedObjectType;
27
+	/**
28
+	 * Object type.
29
+	 *
30
+	 * @var int
31
+	 */
32
+	protected $_digestedObjectType;
33 33
 
34
-    /**
35
-     * OID of other object type.
36
-     *
37
-     * @var null|string
38
-     */
39
-    protected $_otherObjectTypeID;
34
+	/**
35
+	 * OID of other object type.
36
+	 *
37
+	 * @var null|string
38
+	 */
39
+	protected $_otherObjectTypeID;
40 40
 
41
-    /**
42
-     * Digest algorithm.
43
-     *
44
-     * @var AlgorithmIdentifierType
45
-     */
46
-    protected $_digestAlgorithm;
41
+	/**
42
+	 * Digest algorithm.
43
+	 *
44
+	 * @var AlgorithmIdentifierType
45
+	 */
46
+	protected $_digestAlgorithm;
47 47
 
48
-    /**
49
-     * Object digest.
50
-     *
51
-     * @var BitString
52
-     */
53
-    protected $_objectDigest;
48
+	/**
49
+	 * Object digest.
50
+	 *
51
+	 * @var BitString
52
+	 */
53
+	protected $_objectDigest;
54 54
 
55
-    /**
56
-     * Constructor.
57
-     *
58
-     * @param int                     $type
59
-     * @param AlgorithmIdentifierType $algo
60
-     * @param BitString               $digest
61
-     */
62
-    public function __construct(int $type, AlgorithmIdentifierType $algo,
63
-        BitString $digest)
64
-    {
65
-        $this->_digestedObjectType = $type;
66
-        $this->_otherObjectTypeID = null;
67
-        $this->_digestAlgorithm = $algo;
68
-        $this->_objectDigest = $digest;
69
-    }
55
+	/**
56
+	 * Constructor.
57
+	 *
58
+	 * @param int                     $type
59
+	 * @param AlgorithmIdentifierType $algo
60
+	 * @param BitString               $digest
61
+	 */
62
+	public function __construct(int $type, AlgorithmIdentifierType $algo,
63
+		BitString $digest)
64
+	{
65
+		$this->_digestedObjectType = $type;
66
+		$this->_otherObjectTypeID = null;
67
+		$this->_digestAlgorithm = $algo;
68
+		$this->_objectDigest = $digest;
69
+	}
70 70
 
71
-    /**
72
-     * Initialize from ASN.1.
73
-     *
74
-     * @param Sequence $seq
75
-     *
76
-     * @return self
77
-     */
78
-    public static function fromASN1(Sequence $seq): ObjectDigestInfo
79
-    {
80
-        $idx = 0;
81
-        $oid = null;
82
-        $type = $seq->at($idx++)->asEnumerated()->intNumber();
83
-        if ($seq->has($idx, Element::TYPE_OBJECT_IDENTIFIER)) {
84
-            $oid = $seq->at($idx++)->asObjectIdentifier()->oid();
85
-        }
86
-        $algo = AlgorithmIdentifier::fromASN1($seq->at($idx++)->asSequence());
87
-        $digest = $seq->at($idx)->asBitString();
88
-        $obj = new self($type, $algo, $digest);
89
-        $obj->_otherObjectTypeID = $oid;
90
-        return $obj;
91
-    }
71
+	/**
72
+	 * Initialize from ASN.1.
73
+	 *
74
+	 * @param Sequence $seq
75
+	 *
76
+	 * @return self
77
+	 */
78
+	public static function fromASN1(Sequence $seq): ObjectDigestInfo
79
+	{
80
+		$idx = 0;
81
+		$oid = null;
82
+		$type = $seq->at($idx++)->asEnumerated()->intNumber();
83
+		if ($seq->has($idx, Element::TYPE_OBJECT_IDENTIFIER)) {
84
+			$oid = $seq->at($idx++)->asObjectIdentifier()->oid();
85
+		}
86
+		$algo = AlgorithmIdentifier::fromASN1($seq->at($idx++)->asSequence());
87
+		$digest = $seq->at($idx)->asBitString();
88
+		$obj = new self($type, $algo, $digest);
89
+		$obj->_otherObjectTypeID = $oid;
90
+		return $obj;
91
+	}
92 92
 
93
-    /**
94
-     * Generate ASN.1 structure.
95
-     *
96
-     * @return Sequence
97
-     */
98
-    public function toASN1(): Sequence
99
-    {
100
-        $elements = [new Enumerated($this->_digestedObjectType)];
101
-        if (isset($this->_otherObjectTypeID)) {
102
-            $elements[] = new ObjectIdentifier($this->_otherObjectTypeID);
103
-        }
104
-        $elements[] = $this->_digestAlgorithm->toASN1();
105
-        $elements[] = $this->_objectDigest;
106
-        return new Sequence(...$elements);
107
-    }
93
+	/**
94
+	 * Generate ASN.1 structure.
95
+	 *
96
+	 * @return Sequence
97
+	 */
98
+	public function toASN1(): Sequence
99
+	{
100
+		$elements = [new Enumerated($this->_digestedObjectType)];
101
+		if (isset($this->_otherObjectTypeID)) {
102
+			$elements[] = new ObjectIdentifier($this->_otherObjectTypeID);
103
+		}
104
+		$elements[] = $this->_digestAlgorithm->toASN1();
105
+		$elements[] = $this->_objectDigest;
106
+		return new Sequence(...$elements);
107
+	}
108 108
 }
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\X509\AttributeCertificate;
6 6
 
Please login to merge, or discard this patch.
lib/X509/AttributeCertificate/Holder.php 2 patches
Indentation   +264 added lines, -264 removed lines patch added patch discarded remove patch
@@ -19,286 +19,286 @@
 block discarded – undo
19 19
  */
20 20
 class Holder
21 21
 {
22
-    /**
23
-     * Holder PKC's issuer and serial.
24
-     *
25
-     * @var null|IssuerSerial
26
-     */
27
-    protected $_baseCertificateID;
22
+	/**
23
+	 * Holder PKC's issuer and serial.
24
+	 *
25
+	 * @var null|IssuerSerial
26
+	 */
27
+	protected $_baseCertificateID;
28 28
 
29
-    /**
30
-     * Holder PKC's subject.
31
-     *
32
-     * @var null|GeneralNames
33
-     */
34
-    protected $_entityName;
29
+	/**
30
+	 * Holder PKC's subject.
31
+	 *
32
+	 * @var null|GeneralNames
33
+	 */
34
+	protected $_entityName;
35 35
 
36
-    /**
37
-     * Linked object.
38
-     *
39
-     * @var null|ObjectDigestInfo
40
-     */
41
-    protected $_objectDigestInfo;
36
+	/**
37
+	 * Linked object.
38
+	 *
39
+	 * @var null|ObjectDigestInfo
40
+	 */
41
+	protected $_objectDigestInfo;
42 42
 
43
-    /**
44
-     * Constructor.
45
-     *
46
-     * @param null|IssuerSerial $issuer_serial
47
-     * @param null|GeneralNames $entity_name
48
-     */
49
-    public function __construct(?IssuerSerial $issuer_serial = null,
50
-        ?GeneralNames $entity_name = null)
51
-    {
52
-        $this->_baseCertificateID = $issuer_serial;
53
-        $this->_entityName = $entity_name;
54
-    }
43
+	/**
44
+	 * Constructor.
45
+	 *
46
+	 * @param null|IssuerSerial $issuer_serial
47
+	 * @param null|GeneralNames $entity_name
48
+	 */
49
+	public function __construct(?IssuerSerial $issuer_serial = null,
50
+		?GeneralNames $entity_name = null)
51
+	{
52
+		$this->_baseCertificateID = $issuer_serial;
53
+		$this->_entityName = $entity_name;
54
+	}
55 55
 
56
-    /**
57
-     * Initialize from a holder's public key certificate.
58
-     *
59
-     * @param Certificate $cert
60
-     *
61
-     * @return self
62
-     */
63
-    public static function fromPKC(Certificate $cert): self
64
-    {
65
-        return new self(IssuerSerial::fromPKC($cert));
66
-    }
56
+	/**
57
+	 * Initialize from a holder's public key certificate.
58
+	 *
59
+	 * @param Certificate $cert
60
+	 *
61
+	 * @return self
62
+	 */
63
+	public static function fromPKC(Certificate $cert): self
64
+	{
65
+		return new self(IssuerSerial::fromPKC($cert));
66
+	}
67 67
 
68
-    /**
69
-     * Initialize from ASN.1.
70
-     *
71
-     * @param Sequence $seq
72
-     */
73
-    public static function fromASN1(Sequence $seq): self
74
-    {
75
-        $cert_id = null;
76
-        $entity_name = null;
77
-        $digest_info = null;
78
-        if ($seq->hasTagged(0)) {
79
-            $cert_id = IssuerSerial::fromASN1(
80
-                $seq->getTagged(0)->asImplicit(Element::TYPE_SEQUENCE)
81
-                    ->asSequence());
82
-        }
83
-        if ($seq->hasTagged(1)) {
84
-            $entity_name = GeneralNames::fromASN1(
85
-                $seq->getTagged(1)->asImplicit(Element::TYPE_SEQUENCE)
86
-                    ->asSequence());
87
-        }
88
-        if ($seq->hasTagged(2)) {
89
-            $digest_info = ObjectDigestInfo::fromASN1(
90
-                $seq->getTagged(2)->asImplicit(Element::TYPE_SEQUENCE)
91
-                    ->asSequence());
92
-        }
93
-        $obj = new self($cert_id, $entity_name);
94
-        $obj->_objectDigestInfo = $digest_info;
95
-        return $obj;
96
-    }
68
+	/**
69
+	 * Initialize from ASN.1.
70
+	 *
71
+	 * @param Sequence $seq
72
+	 */
73
+	public static function fromASN1(Sequence $seq): self
74
+	{
75
+		$cert_id = null;
76
+		$entity_name = null;
77
+		$digest_info = null;
78
+		if ($seq->hasTagged(0)) {
79
+			$cert_id = IssuerSerial::fromASN1(
80
+				$seq->getTagged(0)->asImplicit(Element::TYPE_SEQUENCE)
81
+					->asSequence());
82
+		}
83
+		if ($seq->hasTagged(1)) {
84
+			$entity_name = GeneralNames::fromASN1(
85
+				$seq->getTagged(1)->asImplicit(Element::TYPE_SEQUENCE)
86
+					->asSequence());
87
+		}
88
+		if ($seq->hasTagged(2)) {
89
+			$digest_info = ObjectDigestInfo::fromASN1(
90
+				$seq->getTagged(2)->asImplicit(Element::TYPE_SEQUENCE)
91
+					->asSequence());
92
+		}
93
+		$obj = new self($cert_id, $entity_name);
94
+		$obj->_objectDigestInfo = $digest_info;
95
+		return $obj;
96
+	}
97 97
 
98
-    /**
99
-     * Get self with base certificate ID.
100
-     *
101
-     * @param IssuerSerial $issuer
102
-     *
103
-     * @return self
104
-     */
105
-    public function withBaseCertificateID(IssuerSerial $issuer): self
106
-    {
107
-        $obj = clone $this;
108
-        $obj->_baseCertificateID = $issuer;
109
-        return $obj;
110
-    }
98
+	/**
99
+	 * Get self with base certificate ID.
100
+	 *
101
+	 * @param IssuerSerial $issuer
102
+	 *
103
+	 * @return self
104
+	 */
105
+	public function withBaseCertificateID(IssuerSerial $issuer): self
106
+	{
107
+		$obj = clone $this;
108
+		$obj->_baseCertificateID = $issuer;
109
+		return $obj;
110
+	}
111 111
 
112
-    /**
113
-     * Get self with entity name.
114
-     *
115
-     * @param GeneralNames $names
116
-     *
117
-     * @return self
118
-     */
119
-    public function withEntityName(GeneralNames $names): self
120
-    {
121
-        $obj = clone $this;
122
-        $obj->_entityName = $names;
123
-        return $obj;
124
-    }
112
+	/**
113
+	 * Get self with entity name.
114
+	 *
115
+	 * @param GeneralNames $names
116
+	 *
117
+	 * @return self
118
+	 */
119
+	public function withEntityName(GeneralNames $names): self
120
+	{
121
+		$obj = clone $this;
122
+		$obj->_entityName = $names;
123
+		return $obj;
124
+	}
125 125
 
126
-    /**
127
-     * Get self with object digest info.
128
-     *
129
-     * @param ObjectDigestInfo $odi
130
-     *
131
-     * @return self
132
-     */
133
-    public function withObjectDigestInfo(ObjectDigestInfo $odi): self
134
-    {
135
-        $obj = clone $this;
136
-        $obj->_objectDigestInfo = $odi;
137
-        return $obj;
138
-    }
126
+	/**
127
+	 * Get self with object digest info.
128
+	 *
129
+	 * @param ObjectDigestInfo $odi
130
+	 *
131
+	 * @return self
132
+	 */
133
+	public function withObjectDigestInfo(ObjectDigestInfo $odi): self
134
+	{
135
+		$obj = clone $this;
136
+		$obj->_objectDigestInfo = $odi;
137
+		return $obj;
138
+	}
139 139
 
140
-    /**
141
-     * Check whether base certificate ID is present.
142
-     *
143
-     * @return bool
144
-     */
145
-    public function hasBaseCertificateID(): bool
146
-    {
147
-        return isset($this->_baseCertificateID);
148
-    }
140
+	/**
141
+	 * Check whether base certificate ID is present.
142
+	 *
143
+	 * @return bool
144
+	 */
145
+	public function hasBaseCertificateID(): bool
146
+	{
147
+		return isset($this->_baseCertificateID);
148
+	}
149 149
 
150
-    /**
151
-     * Get base certificate ID.
152
-     *
153
-     * @throws \LogicException If not set
154
-     *
155
-     * @return IssuerSerial
156
-     */
157
-    public function baseCertificateID(): IssuerSerial
158
-    {
159
-        if (!$this->hasBaseCertificateID()) {
160
-            throw new \LogicException('baseCertificateID not set.');
161
-        }
162
-        return $this->_baseCertificateID;
163
-    }
150
+	/**
151
+	 * Get base certificate ID.
152
+	 *
153
+	 * @throws \LogicException If not set
154
+	 *
155
+	 * @return IssuerSerial
156
+	 */
157
+	public function baseCertificateID(): IssuerSerial
158
+	{
159
+		if (!$this->hasBaseCertificateID()) {
160
+			throw new \LogicException('baseCertificateID not set.');
161
+		}
162
+		return $this->_baseCertificateID;
163
+	}
164 164
 
165
-    /**
166
-     * Check whether entity name is present.
167
-     *
168
-     * @return bool
169
-     */
170
-    public function hasEntityName(): bool
171
-    {
172
-        return isset($this->_entityName);
173
-    }
165
+	/**
166
+	 * Check whether entity name is present.
167
+	 *
168
+	 * @return bool
169
+	 */
170
+	public function hasEntityName(): bool
171
+	{
172
+		return isset($this->_entityName);
173
+	}
174 174
 
175
-    /**
176
-     * Get entity name.
177
-     *
178
-     * @throws \LogicException If not set
179
-     *
180
-     * @return GeneralNames
181
-     */
182
-    public function entityName(): GeneralNames
183
-    {
184
-        if (!$this->hasEntityName()) {
185
-            throw new \LogicException('entityName not set.');
186
-        }
187
-        return $this->_entityName;
188
-    }
175
+	/**
176
+	 * Get entity name.
177
+	 *
178
+	 * @throws \LogicException If not set
179
+	 *
180
+	 * @return GeneralNames
181
+	 */
182
+	public function entityName(): GeneralNames
183
+	{
184
+		if (!$this->hasEntityName()) {
185
+			throw new \LogicException('entityName not set.');
186
+		}
187
+		return $this->_entityName;
188
+	}
189 189
 
190
-    /**
191
-     * Check whether object digest info is present.
192
-     *
193
-     * @return bool
194
-     */
195
-    public function hasObjectDigestInfo(): bool
196
-    {
197
-        return isset($this->_objectDigestInfo);
198
-    }
190
+	/**
191
+	 * Check whether object digest info is present.
192
+	 *
193
+	 * @return bool
194
+	 */
195
+	public function hasObjectDigestInfo(): bool
196
+	{
197
+		return isset($this->_objectDigestInfo);
198
+	}
199 199
 
200
-    /**
201
-     * Get object digest info.
202
-     *
203
-     * @throws \LogicException If not set
204
-     *
205
-     * @return ObjectDigestInfo
206
-     */
207
-    public function objectDigestInfo(): ObjectDigestInfo
208
-    {
209
-        if (!$this->hasObjectDigestInfo()) {
210
-            throw new \LogicException('objectDigestInfo not set.');
211
-        }
212
-        return $this->_objectDigestInfo;
213
-    }
200
+	/**
201
+	 * Get object digest info.
202
+	 *
203
+	 * @throws \LogicException If not set
204
+	 *
205
+	 * @return ObjectDigestInfo
206
+	 */
207
+	public function objectDigestInfo(): ObjectDigestInfo
208
+	{
209
+		if (!$this->hasObjectDigestInfo()) {
210
+			throw new \LogicException('objectDigestInfo not set.');
211
+		}
212
+		return $this->_objectDigestInfo;
213
+	}
214 214
 
215
-    /**
216
-     * Generate ASN.1 structure.
217
-     *
218
-     * @return Sequence
219
-     */
220
-    public function toASN1(): Sequence
221
-    {
222
-        $elements = [];
223
-        if (isset($this->_baseCertificateID)) {
224
-            $elements[] = new ImplicitlyTaggedType(0,
225
-                $this->_baseCertificateID->toASN1());
226
-        }
227
-        if (isset($this->_entityName)) {
228
-            $elements[] = new ImplicitlyTaggedType(1,
229
-                $this->_entityName->toASN1());
230
-        }
231
-        if (isset($this->_objectDigestInfo)) {
232
-            $elements[] = new ImplicitlyTaggedType(2,
233
-                $this->_objectDigestInfo->toASN1());
234
-        }
235
-        return new Sequence(...$elements);
236
-    }
215
+	/**
216
+	 * Generate ASN.1 structure.
217
+	 *
218
+	 * @return Sequence
219
+	 */
220
+	public function toASN1(): Sequence
221
+	{
222
+		$elements = [];
223
+		if (isset($this->_baseCertificateID)) {
224
+			$elements[] = new ImplicitlyTaggedType(0,
225
+				$this->_baseCertificateID->toASN1());
226
+		}
227
+		if (isset($this->_entityName)) {
228
+			$elements[] = new ImplicitlyTaggedType(1,
229
+				$this->_entityName->toASN1());
230
+		}
231
+		if (isset($this->_objectDigestInfo)) {
232
+			$elements[] = new ImplicitlyTaggedType(2,
233
+				$this->_objectDigestInfo->toASN1());
234
+		}
235
+		return new Sequence(...$elements);
236
+	}
237 237
 
238
-    /**
239
-     * Check whether Holder identifies given certificate.
240
-     *
241
-     * @param Certificate $cert
242
-     *
243
-     * @return bool
244
-     */
245
-    public function identifiesPKC(Certificate $cert): bool
246
-    {
247
-        // if neither baseCertificateID nor entityName are present
248
-        if (!$this->_baseCertificateID && !$this->_entityName) {
249
-            return false;
250
-        }
251
-        // if baseCertificateID is present, but doesn't match
252
-        if ($this->_baseCertificateID &&
253
-            !$this->_baseCertificateID->identifiesPKC($cert)) {
254
-            return false;
255
-        }
256
-        // if entityName is present, but doesn't match
257
-        if ($this->_entityName && !$this->_checkEntityName($cert)) {
258
-            return false;
259
-        }
260
-        return true;
261
-    }
238
+	/**
239
+	 * Check whether Holder identifies given certificate.
240
+	 *
241
+	 * @param Certificate $cert
242
+	 *
243
+	 * @return bool
244
+	 */
245
+	public function identifiesPKC(Certificate $cert): bool
246
+	{
247
+		// if neither baseCertificateID nor entityName are present
248
+		if (!$this->_baseCertificateID && !$this->_entityName) {
249
+			return false;
250
+		}
251
+		// if baseCertificateID is present, but doesn't match
252
+		if ($this->_baseCertificateID &&
253
+			!$this->_baseCertificateID->identifiesPKC($cert)) {
254
+			return false;
255
+		}
256
+		// if entityName is present, but doesn't match
257
+		if ($this->_entityName && !$this->_checkEntityName($cert)) {
258
+			return false;
259
+		}
260
+		return true;
261
+	}
262 262
 
263
-    /**
264
-     * Check whether entityName matches the given certificate.
265
-     *
266
-     * @param Certificate $cert
267
-     *
268
-     * @return bool
269
-     */
270
-    private function _checkEntityName(Certificate $cert): bool
271
-    {
272
-        $name = $this->_entityName->firstDN();
273
-        if ($cert->tbsCertificate()->subject()->equals($name)) {
274
-            return true;
275
-        }
276
-        $exts = $cert->tbsCertificate()->extensions();
277
-        if ($exts->hasSubjectAlternativeName()) {
278
-            $ext = $exts->subjectAlternativeName();
279
-            if ($this->_checkEntityAlternativeNames($ext->names())) {
280
-                return true;
281
-            }
282
-        }
283
-        return false;
284
-    }
263
+	/**
264
+	 * Check whether entityName matches the given certificate.
265
+	 *
266
+	 * @param Certificate $cert
267
+	 *
268
+	 * @return bool
269
+	 */
270
+	private function _checkEntityName(Certificate $cert): bool
271
+	{
272
+		$name = $this->_entityName->firstDN();
273
+		if ($cert->tbsCertificate()->subject()->equals($name)) {
274
+			return true;
275
+		}
276
+		$exts = $cert->tbsCertificate()->extensions();
277
+		if ($exts->hasSubjectAlternativeName()) {
278
+			$ext = $exts->subjectAlternativeName();
279
+			if ($this->_checkEntityAlternativeNames($ext->names())) {
280
+				return true;
281
+			}
282
+		}
283
+		return false;
284
+	}
285 285
 
286
-    /**
287
-     * Check whether any of the subject alternative names match entityName.
288
-     *
289
-     * @param GeneralNames $san
290
-     *
291
-     * @return bool
292
-     */
293
-    private function _checkEntityAlternativeNames(GeneralNames $san): bool
294
-    {
295
-        // only directory names supported for now
296
-        $name = $this->_entityName->firstDN();
297
-        foreach ($san->allOf(GeneralName::TAG_DIRECTORY_NAME) as $dn) {
298
-            if ($dn instanceof DirectoryName && $dn->dn()->equals($name)) {
299
-                return true;
300
-            }
301
-        }
302
-        return false;
303
-    }
286
+	/**
287
+	 * Check whether any of the subject alternative names match entityName.
288
+	 *
289
+	 * @param GeneralNames $san
290
+	 *
291
+	 * @return bool
292
+	 */
293
+	private function _checkEntityAlternativeNames(GeneralNames $san): bool
294
+	{
295
+		// only directory names supported for now
296
+		$name = $this->_entityName->firstDN();
297
+		foreach ($san->allOf(GeneralName::TAG_DIRECTORY_NAME) as $dn) {
298
+			if ($dn instanceof DirectoryName && $dn->dn()->equals($name)) {
299
+				return true;
300
+			}
301
+		}
302
+		return false;
303
+	}
304 304
 }
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\X509\AttributeCertificate;
6 6
 
Please login to merge, or discard this patch.
lib/X509/AttributeCertificate/V2Form.php 2 patches
Indentation   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -18,137 +18,137 @@
 block discarded – undo
18 18
  */
19 19
 class V2Form extends AttCertIssuer
20 20
 {
21
-    /**
22
-     * Issuer name.
23
-     *
24
-     * @var null|GeneralNames
25
-     */
26
-    protected $_issuerName;
21
+	/**
22
+	 * Issuer name.
23
+	 *
24
+	 * @var null|GeneralNames
25
+	 */
26
+	protected $_issuerName;
27 27
 
28
-    /**
29
-     * Issuer PKC's issuer and serial.
30
-     *
31
-     * @var IssuerSerial
32
-     */
33
-    protected $_baseCertificateID;
28
+	/**
29
+	 * Issuer PKC's issuer and serial.
30
+	 *
31
+	 * @var IssuerSerial
32
+	 */
33
+	protected $_baseCertificateID;
34 34
 
35
-    /**
36
-     * Linked object.
37
-     *
38
-     * @var ObjectDigestInfo
39
-     */
40
-    protected $_objectDigestInfo;
35
+	/**
36
+	 * Linked object.
37
+	 *
38
+	 * @var ObjectDigestInfo
39
+	 */
40
+	protected $_objectDigestInfo;
41 41
 
42
-    /**
43
-     * Constructor.
44
-     *
45
-     * @param null|GeneralNames $names
46
-     */
47
-    public function __construct(?GeneralNames $names = null)
48
-    {
49
-        $this->_issuerName = $names;
50
-        $this->_baseCertificateID = null;
51
-        $this->_objectDigestInfo = null;
52
-    }
42
+	/**
43
+	 * Constructor.
44
+	 *
45
+	 * @param null|GeneralNames $names
46
+	 */
47
+	public function __construct(?GeneralNames $names = null)
48
+	{
49
+		$this->_issuerName = $names;
50
+		$this->_baseCertificateID = null;
51
+		$this->_objectDigestInfo = null;
52
+	}
53 53
 
54
-    /**
55
-     * Initialize from ASN.1.
56
-     *
57
-     * @param Sequence $seq
58
-     *
59
-     * @return self
60
-     */
61
-    public static function fromV2ASN1(Sequence $seq): self
62
-    {
63
-        $issuer = null;
64
-        $cert_id = null;
65
-        $digest_info = null;
66
-        if ($seq->has(0, Element::TYPE_SEQUENCE)) {
67
-            $issuer = GeneralNames::fromASN1($seq->at(0)->asSequence());
68
-        }
69
-        if ($seq->hasTagged(0)) {
70
-            $cert_id = IssuerSerial::fromASN1(
71
-                $seq->getTagged(0)->asImplicit(Element::TYPE_SEQUENCE)
72
-                    ->asSequence());
73
-        }
74
-        if ($seq->hasTagged(1)) {
75
-            $digest_info = ObjectDigestInfo::fromASN1(
76
-                $seq->getTagged(1)->asImplicit(Element::TYPE_SEQUENCE)
77
-                    ->asSequence());
78
-        }
79
-        $obj = new self($issuer);
80
-        $obj->_baseCertificateID = $cert_id;
81
-        $obj->_objectDigestInfo = $digest_info;
82
-        return $obj;
83
-    }
54
+	/**
55
+	 * Initialize from ASN.1.
56
+	 *
57
+	 * @param Sequence $seq
58
+	 *
59
+	 * @return self
60
+	 */
61
+	public static function fromV2ASN1(Sequence $seq): self
62
+	{
63
+		$issuer = null;
64
+		$cert_id = null;
65
+		$digest_info = null;
66
+		if ($seq->has(0, Element::TYPE_SEQUENCE)) {
67
+			$issuer = GeneralNames::fromASN1($seq->at(0)->asSequence());
68
+		}
69
+		if ($seq->hasTagged(0)) {
70
+			$cert_id = IssuerSerial::fromASN1(
71
+				$seq->getTagged(0)->asImplicit(Element::TYPE_SEQUENCE)
72
+					->asSequence());
73
+		}
74
+		if ($seq->hasTagged(1)) {
75
+			$digest_info = ObjectDigestInfo::fromASN1(
76
+				$seq->getTagged(1)->asImplicit(Element::TYPE_SEQUENCE)
77
+					->asSequence());
78
+		}
79
+		$obj = new self($issuer);
80
+		$obj->_baseCertificateID = $cert_id;
81
+		$obj->_objectDigestInfo = $digest_info;
82
+		return $obj;
83
+	}
84 84
 
85
-    /**
86
-     * Check whether issuer name is set.
87
-     *
88
-     * @return bool
89
-     */
90
-    public function hasIssuerName(): bool
91
-    {
92
-        return isset($this->_issuerName);
93
-    }
85
+	/**
86
+	 * Check whether issuer name is set.
87
+	 *
88
+	 * @return bool
89
+	 */
90
+	public function hasIssuerName(): bool
91
+	{
92
+		return isset($this->_issuerName);
93
+	}
94 94
 
95
-    /**
96
-     * Get issuer name.
97
-     *
98
-     * @throws \LogicException If not set
99
-     *
100
-     * @return GeneralNames
101
-     */
102
-    public function issuerName(): GeneralNames
103
-    {
104
-        if (!$this->hasIssuerName()) {
105
-            throw new \LogicException('issuerName not set.');
106
-        }
107
-        return $this->_issuerName;
108
-    }
95
+	/**
96
+	 * Get issuer name.
97
+	 *
98
+	 * @throws \LogicException If not set
99
+	 *
100
+	 * @return GeneralNames
101
+	 */
102
+	public function issuerName(): GeneralNames
103
+	{
104
+		if (!$this->hasIssuerName()) {
105
+			throw new \LogicException('issuerName not set.');
106
+		}
107
+		return $this->_issuerName;
108
+	}
109 109
 
110
-    /**
111
-     * Get DN of the issuer.
112
-     *
113
-     * This is a convenience method conforming to RFC 5755, which states
114
-     * that Issuer must contain only one non-empty distinguished name.
115
-     *
116
-     * @return Name
117
-     */
118
-    public function name(): Name
119
-    {
120
-        return $this->issuerName()->firstDN();
121
-    }
110
+	/**
111
+	 * Get DN of the issuer.
112
+	 *
113
+	 * This is a convenience method conforming to RFC 5755, which states
114
+	 * that Issuer must contain only one non-empty distinguished name.
115
+	 *
116
+	 * @return Name
117
+	 */
118
+	public function name(): Name
119
+	{
120
+		return $this->issuerName()->firstDN();
121
+	}
122 122
 
123
-    /**
124
-     * {@inheritdoc}
125
-     */
126
-    public function toASN1(): Element
127
-    {
128
-        $elements = [];
129
-        if (isset($this->_issuerName)) {
130
-            $elements[] = $this->_issuerName->toASN1();
131
-        }
132
-        if (isset($this->_baseCertificateID)) {
133
-            $elements[] = new ImplicitlyTaggedType(0,
134
-                $this->_baseCertificateID->toASN1());
135
-        }
136
-        if (isset($this->_objectDigestInfo)) {
137
-            $elements[] = new ImplicitlyTaggedType(1,
138
-                $this->_objectDigestInfo->toASN1());
139
-        }
140
-        return new ImplicitlyTaggedType(0, new Sequence(...$elements));
141
-    }
123
+	/**
124
+	 * {@inheritdoc}
125
+	 */
126
+	public function toASN1(): Element
127
+	{
128
+		$elements = [];
129
+		if (isset($this->_issuerName)) {
130
+			$elements[] = $this->_issuerName->toASN1();
131
+		}
132
+		if (isset($this->_baseCertificateID)) {
133
+			$elements[] = new ImplicitlyTaggedType(0,
134
+				$this->_baseCertificateID->toASN1());
135
+		}
136
+		if (isset($this->_objectDigestInfo)) {
137
+			$elements[] = new ImplicitlyTaggedType(1,
138
+				$this->_objectDigestInfo->toASN1());
139
+		}
140
+		return new ImplicitlyTaggedType(0, new Sequence(...$elements));
141
+	}
142 142
 
143
-    /**
144
-     * {@inheritdoc}
145
-     */
146
-    public function identifiesPKC(Certificate $cert): bool
147
-    {
148
-        $name = $this->_issuerName->firstDN();
149
-        if (!$cert->tbsCertificate()->subject()->equals($name)) {
150
-            return false;
151
-        }
152
-        return true;
153
-    }
143
+	/**
144
+	 * {@inheritdoc}
145
+	 */
146
+	public function identifiesPKC(Certificate $cert): bool
147
+	{
148
+		$name = $this->_issuerName->firstDN();
149
+		if (!$cert->tbsCertificate()->subject()->equals($name)) {
150
+			return false;
151
+		}
152
+		return true;
153
+	}
154 154
 }
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\X509\AttributeCertificate;
6 6
 
Please login to merge, or discard this patch.
lib/X509/AttributeCertificate/AttCertValidityPeriod.php 2 patches
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -15,93 +15,93 @@
 block discarded – undo
15 15
  */
16 16
 class AttCertValidityPeriod
17 17
 {
18
-    use DateTimeHelper;
18
+	use DateTimeHelper;
19 19
 
20
-    /**
21
-     * Not before time.
22
-     *
23
-     * @var \DateTimeImmutable
24
-     */
25
-    protected $_notBeforeTime;
20
+	/**
21
+	 * Not before time.
22
+	 *
23
+	 * @var \DateTimeImmutable
24
+	 */
25
+	protected $_notBeforeTime;
26 26
 
27
-    /**
28
-     * Not after time.
29
-     *
30
-     * @var \DateTimeImmutable
31
-     */
32
-    protected $_notAfterTime;
27
+	/**
28
+	 * Not after time.
29
+	 *
30
+	 * @var \DateTimeImmutable
31
+	 */
32
+	protected $_notAfterTime;
33 33
 
34
-    /**
35
-     * Constructor.
36
-     *
37
-     * @param \DateTimeImmutable $nb
38
-     * @param \DateTimeImmutable $na
39
-     */
40
-    public function __construct(\DateTimeImmutable $nb, \DateTimeImmutable $na)
41
-    {
42
-        $this->_notBeforeTime = $nb;
43
-        $this->_notAfterTime = $na;
44
-    }
34
+	/**
35
+	 * Constructor.
36
+	 *
37
+	 * @param \DateTimeImmutable $nb
38
+	 * @param \DateTimeImmutable $na
39
+	 */
40
+	public function __construct(\DateTimeImmutable $nb, \DateTimeImmutable $na)
41
+	{
42
+		$this->_notBeforeTime = $nb;
43
+		$this->_notAfterTime = $na;
44
+	}
45 45
 
46
-    /**
47
-     * Initialize from ASN.1.
48
-     *
49
-     * @param Sequence $seq
50
-     *
51
-     * @return self
52
-     */
53
-    public static function fromASN1(Sequence $seq): self
54
-    {
55
-        $nb = $seq->at(0)->asGeneralizedTime()->dateTime();
56
-        $na = $seq->at(1)->asGeneralizedTime()->dateTime();
57
-        return new self($nb, $na);
58
-    }
46
+	/**
47
+	 * Initialize from ASN.1.
48
+	 *
49
+	 * @param Sequence $seq
50
+	 *
51
+	 * @return self
52
+	 */
53
+	public static function fromASN1(Sequence $seq): self
54
+	{
55
+		$nb = $seq->at(0)->asGeneralizedTime()->dateTime();
56
+		$na = $seq->at(1)->asGeneralizedTime()->dateTime();
57
+		return new self($nb, $na);
58
+	}
59 59
 
60
-    /**
61
-     * Initialize from date strings.
62
-     *
63
-     * @param null|string $nb_date Not before date
64
-     * @param null|string $na_date Not after date
65
-     * @param null|string $tz      Timezone string
66
-     *
67
-     * @return self
68
-     */
69
-    public static function fromStrings(?string $nb_date, ?string $na_date,
70
-        ?string $tz = null): self
71
-    {
72
-        $nb = self::_createDateTime($nb_date, $tz);
73
-        $na = self::_createDateTime($na_date, $tz);
74
-        return new self($nb, $na);
75
-    }
60
+	/**
61
+	 * Initialize from date strings.
62
+	 *
63
+	 * @param null|string $nb_date Not before date
64
+	 * @param null|string $na_date Not after date
65
+	 * @param null|string $tz      Timezone string
66
+	 *
67
+	 * @return self
68
+	 */
69
+	public static function fromStrings(?string $nb_date, ?string $na_date,
70
+		?string $tz = null): self
71
+	{
72
+		$nb = self::_createDateTime($nb_date, $tz);
73
+		$na = self::_createDateTime($na_date, $tz);
74
+		return new self($nb, $na);
75
+	}
76 76
 
77
-    /**
78
-     * Get not before time.
79
-     *
80
-     * @return \DateTimeImmutable
81
-     */
82
-    public function notBeforeTime(): \DateTimeImmutable
83
-    {
84
-        return $this->_notBeforeTime;
85
-    }
77
+	/**
78
+	 * Get not before time.
79
+	 *
80
+	 * @return \DateTimeImmutable
81
+	 */
82
+	public function notBeforeTime(): \DateTimeImmutable
83
+	{
84
+		return $this->_notBeforeTime;
85
+	}
86 86
 
87
-    /**
88
-     * Get not after time.
89
-     *
90
-     * @return \DateTimeImmutable
91
-     */
92
-    public function notAfterTime(): \DateTimeImmutable
93
-    {
94
-        return $this->_notAfterTime;
95
-    }
87
+	/**
88
+	 * Get not after time.
89
+	 *
90
+	 * @return \DateTimeImmutable
91
+	 */
92
+	public function notAfterTime(): \DateTimeImmutable
93
+	{
94
+		return $this->_notAfterTime;
95
+	}
96 96
 
97
-    /**
98
-     * Generate ASN.1 structure.
99
-     *
100
-     * @return Sequence
101
-     */
102
-    public function toASN1(): Sequence
103
-    {
104
-        return new Sequence(new GeneralizedTime($this->_notBeforeTime),
105
-            new GeneralizedTime($this->_notAfterTime));
106
-    }
97
+	/**
98
+	 * Generate ASN.1 structure.
99
+	 *
100
+	 * @return Sequence
101
+	 */
102
+	public function toASN1(): Sequence
103
+	{
104
+		return new Sequence(new GeneralizedTime($this->_notBeforeTime),
105
+			new GeneralizedTime($this->_notAfterTime));
106
+	}
107 107
 }
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\X509\AttributeCertificate;
6 6
 
Please login to merge, or discard this patch.
lib/X509/CertificationRequest/CertificationRequest.php 2 patches
Indentation   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -19,175 +19,175 @@
 block discarded – undo
19 19
  */
20 20
 class CertificationRequest
21 21
 {
22
-    /**
23
-     * Certification request info.
24
-     *
25
-     * @var CertificationRequestInfo
26
-     */
27
-    protected $_certificationRequestInfo;
28
-
29
-    /**
30
-     * Signature algorithm.
31
-     *
32
-     * @var SignatureAlgorithmIdentifier
33
-     */
34
-    protected $_signatureAlgorithm;
35
-
36
-    /**
37
-     * Signature.
38
-     *
39
-     * @var Signature
40
-     */
41
-    protected $_signature;
42
-
43
-    /**
44
-     * Constructor.
45
-     *
46
-     * @param CertificationRequestInfo     $info
47
-     * @param SignatureAlgorithmIdentifier $algo
48
-     * @param Signature                    $signature
49
-     */
50
-    public function __construct(CertificationRequestInfo $info,
51
-        SignatureAlgorithmIdentifier $algo, Signature $signature)
52
-    {
53
-        $this->_certificationRequestInfo = $info;
54
-        $this->_signatureAlgorithm = $algo;
55
-        $this->_signature = $signature;
56
-    }
57
-
58
-    /**
59
-     * Get certification request as a PEM formatted string.
60
-     *
61
-     * @return string
62
-     */
63
-    public function __toString(): string
64
-    {
65
-        return $this->toPEM()->string();
66
-    }
67
-
68
-    /**
69
-     * Initialize from ASN.1.
70
-     *
71
-     * @param Sequence $seq
72
-     *
73
-     * @return self
74
-     */
75
-    public static function fromASN1(Sequence $seq): self
76
-    {
77
-        $info = CertificationRequestInfo::fromASN1($seq->at(0)->asSequence());
78
-        $algo = AlgorithmIdentifier::fromASN1($seq->at(1)->asSequence());
79
-        if (!$algo instanceof SignatureAlgorithmIdentifier) {
80
-            throw new \UnexpectedValueException(
81
-                'Unsupported signature algorithm ' . $algo->oid() . '.');
82
-        }
83
-        $signature = Signature::fromSignatureData(
84
-            $seq->at(2)->asBitString()->string(), $algo);
85
-        return new self($info, $algo, $signature);
86
-    }
87
-
88
-    /**
89
-     * Initialize from DER.
90
-     *
91
-     * @param string $data
92
-     *
93
-     * @return self
94
-     */
95
-    public static function fromDER(string $data): self
96
-    {
97
-        return self::fromASN1(UnspecifiedType::fromDER($data)->asSequence());
98
-    }
99
-
100
-    /**
101
-     * Initialize from PEM.
102
-     *
103
-     * @param PEM $pem
104
-     *
105
-     * @throws \UnexpectedValueException
106
-     *
107
-     * @return self
108
-     */
109
-    public static function fromPEM(PEM $pem): self
110
-    {
111
-        if (PEM::TYPE_CERTIFICATE_REQUEST !== $pem->type()) {
112
-            throw new \UnexpectedValueException('Invalid PEM type.');
113
-        }
114
-        return self::fromDER($pem->data());
115
-    }
116
-
117
-    /**
118
-     * Get certification request info.
119
-     *
120
-     * @return CertificationRequestInfo
121
-     */
122
-    public function certificationRequestInfo(): CertificationRequestInfo
123
-    {
124
-        return $this->_certificationRequestInfo;
125
-    }
126
-
127
-    /**
128
-     * Get signature algorithm.
129
-     *
130
-     * @return SignatureAlgorithmIdentifier
131
-     */
132
-    public function signatureAlgorithm(): SignatureAlgorithmIdentifier
133
-    {
134
-        return $this->_signatureAlgorithm;
135
-    }
136
-
137
-    /**
138
-     * Get signature.
139
-     *
140
-     * @return Signature
141
-     */
142
-    public function signature(): Signature
143
-    {
144
-        return $this->_signature;
145
-    }
146
-
147
-    /**
148
-     * Generate ASN.1 structure.
149
-     *
150
-     * @return Sequence
151
-     */
152
-    public function toASN1(): Sequence
153
-    {
154
-        return new Sequence($this->_certificationRequestInfo->toASN1(),
155
-            $this->_signatureAlgorithm->toASN1(), $this->_signature->bitString());
156
-    }
157
-
158
-    /**
159
-     * Get certification request as a DER.
160
-     *
161
-     * @return string
162
-     */
163
-    public function toDER(): string
164
-    {
165
-        return $this->toASN1()->toDER();
166
-    }
167
-
168
-    /**
169
-     * Get certification request as a PEM.
170
-     *
171
-     * @return PEM
172
-     */
173
-    public function toPEM(): PEM
174
-    {
175
-        return new PEM(PEM::TYPE_CERTIFICATE_REQUEST, $this->toDER());
176
-    }
177
-
178
-    /**
179
-     * Verify certification request signature.
180
-     *
181
-     * @param null|Crypto $crypto Crypto engine, use default if not set
182
-     *
183
-     * @return bool True if signature matches
184
-     */
185
-    public function verify(?Crypto $crypto = null): bool
186
-    {
187
-        $crypto = $crypto ?? Crypto::getDefault();
188
-        $data = $this->_certificationRequestInfo->toASN1()->toDER();
189
-        $pk_info = $this->_certificationRequestInfo->subjectPKInfo();
190
-        return $crypto->verify($data, $this->_signature, $pk_info,
191
-            $this->_signatureAlgorithm);
192
-    }
22
+	/**
23
+	 * Certification request info.
24
+	 *
25
+	 * @var CertificationRequestInfo
26
+	 */
27
+	protected $_certificationRequestInfo;
28
+
29
+	/**
30
+	 * Signature algorithm.
31
+	 *
32
+	 * @var SignatureAlgorithmIdentifier
33
+	 */
34
+	protected $_signatureAlgorithm;
35
+
36
+	/**
37
+	 * Signature.
38
+	 *
39
+	 * @var Signature
40
+	 */
41
+	protected $_signature;
42
+
43
+	/**
44
+	 * Constructor.
45
+	 *
46
+	 * @param CertificationRequestInfo     $info
47
+	 * @param SignatureAlgorithmIdentifier $algo
48
+	 * @param Signature                    $signature
49
+	 */
50
+	public function __construct(CertificationRequestInfo $info,
51
+		SignatureAlgorithmIdentifier $algo, Signature $signature)
52
+	{
53
+		$this->_certificationRequestInfo = $info;
54
+		$this->_signatureAlgorithm = $algo;
55
+		$this->_signature = $signature;
56
+	}
57
+
58
+	/**
59
+	 * Get certification request as a PEM formatted string.
60
+	 *
61
+	 * @return string
62
+	 */
63
+	public function __toString(): string
64
+	{
65
+		return $this->toPEM()->string();
66
+	}
67
+
68
+	/**
69
+	 * Initialize from ASN.1.
70
+	 *
71
+	 * @param Sequence $seq
72
+	 *
73
+	 * @return self
74
+	 */
75
+	public static function fromASN1(Sequence $seq): self
76
+	{
77
+		$info = CertificationRequestInfo::fromASN1($seq->at(0)->asSequence());
78
+		$algo = AlgorithmIdentifier::fromASN1($seq->at(1)->asSequence());
79
+		if (!$algo instanceof SignatureAlgorithmIdentifier) {
80
+			throw new \UnexpectedValueException(
81
+				'Unsupported signature algorithm ' . $algo->oid() . '.');
82
+		}
83
+		$signature = Signature::fromSignatureData(
84
+			$seq->at(2)->asBitString()->string(), $algo);
85
+		return new self($info, $algo, $signature);
86
+	}
87
+
88
+	/**
89
+	 * Initialize from DER.
90
+	 *
91
+	 * @param string $data
92
+	 *
93
+	 * @return self
94
+	 */
95
+	public static function fromDER(string $data): self
96
+	{
97
+		return self::fromASN1(UnspecifiedType::fromDER($data)->asSequence());
98
+	}
99
+
100
+	/**
101
+	 * Initialize from PEM.
102
+	 *
103
+	 * @param PEM $pem
104
+	 *
105
+	 * @throws \UnexpectedValueException
106
+	 *
107
+	 * @return self
108
+	 */
109
+	public static function fromPEM(PEM $pem): self
110
+	{
111
+		if (PEM::TYPE_CERTIFICATE_REQUEST !== $pem->type()) {
112
+			throw new \UnexpectedValueException('Invalid PEM type.');
113
+		}
114
+		return self::fromDER($pem->data());
115
+	}
116
+
117
+	/**
118
+	 * Get certification request info.
119
+	 *
120
+	 * @return CertificationRequestInfo
121
+	 */
122
+	public function certificationRequestInfo(): CertificationRequestInfo
123
+	{
124
+		return $this->_certificationRequestInfo;
125
+	}
126
+
127
+	/**
128
+	 * Get signature algorithm.
129
+	 *
130
+	 * @return SignatureAlgorithmIdentifier
131
+	 */
132
+	public function signatureAlgorithm(): SignatureAlgorithmIdentifier
133
+	{
134
+		return $this->_signatureAlgorithm;
135
+	}
136
+
137
+	/**
138
+	 * Get signature.
139
+	 *
140
+	 * @return Signature
141
+	 */
142
+	public function signature(): Signature
143
+	{
144
+		return $this->_signature;
145
+	}
146
+
147
+	/**
148
+	 * Generate ASN.1 structure.
149
+	 *
150
+	 * @return Sequence
151
+	 */
152
+	public function toASN1(): Sequence
153
+	{
154
+		return new Sequence($this->_certificationRequestInfo->toASN1(),
155
+			$this->_signatureAlgorithm->toASN1(), $this->_signature->bitString());
156
+	}
157
+
158
+	/**
159
+	 * Get certification request as a DER.
160
+	 *
161
+	 * @return string
162
+	 */
163
+	public function toDER(): string
164
+	{
165
+		return $this->toASN1()->toDER();
166
+	}
167
+
168
+	/**
169
+	 * Get certification request as a PEM.
170
+	 *
171
+	 * @return PEM
172
+	 */
173
+	public function toPEM(): PEM
174
+	{
175
+		return new PEM(PEM::TYPE_CERTIFICATE_REQUEST, $this->toDER());
176
+	}
177
+
178
+	/**
179
+	 * Verify certification request signature.
180
+	 *
181
+	 * @param null|Crypto $crypto Crypto engine, use default if not set
182
+	 *
183
+	 * @return bool True if signature matches
184
+	 */
185
+	public function verify(?Crypto $crypto = null): bool
186
+	{
187
+		$crypto = $crypto ?? Crypto::getDefault();
188
+		$data = $this->_certificationRequestInfo->toASN1()->toDER();
189
+		$pk_info = $this->_certificationRequestInfo->subjectPKInfo();
190
+		return $crypto->verify($data, $this->_signature, $pk_info,
191
+			$this->_signatureAlgorithm);
192
+	}
193 193
 }
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\X509\CertificationRequest;
6 6
 
Please login to merge, or discard this patch.
lib/X509/CertificationRequest/Attribute/ExtensionRequestValue.php 2 patches
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -18,83 +18,83 @@
 block discarded – undo
18 18
  */
19 19
 class ExtensionRequestValue extends AttributeValue
20 20
 {
21
-    const OID = '1.2.840.113549.1.9.14';
21
+	const OID = '1.2.840.113549.1.9.14';
22 22
 
23
-    /**
24
-     * Extensions.
25
-     *
26
-     * @var Extensions
27
-     */
28
-    protected $_extensions;
23
+	/**
24
+	 * Extensions.
25
+	 *
26
+	 * @var Extensions
27
+	 */
28
+	protected $_extensions;
29 29
 
30
-    /**
31
-     * Constructor.
32
-     *
33
-     * @param Extensions $extensions
34
-     */
35
-    public function __construct(Extensions $extensions)
36
-    {
37
-        $this->_extensions = $extensions;
38
-        $this->_oid = self::OID;
39
-    }
30
+	/**
31
+	 * Constructor.
32
+	 *
33
+	 * @param Extensions $extensions
34
+	 */
35
+	public function __construct(Extensions $extensions)
36
+	{
37
+		$this->_extensions = $extensions;
38
+		$this->_oid = self::OID;
39
+	}
40 40
 
41
-    /**
42
-     * {@inheritdoc}
43
-     *
44
-     * @return self
45
-     */
46
-    public static function fromASN1(UnspecifiedType $el): AttributeValue
47
-    {
48
-        return new self(Extensions::fromASN1($el->asSequence()));
49
-    }
41
+	/**
42
+	 * {@inheritdoc}
43
+	 *
44
+	 * @return self
45
+	 */
46
+	public static function fromASN1(UnspecifiedType $el): AttributeValue
47
+	{
48
+		return new self(Extensions::fromASN1($el->asSequence()));
49
+	}
50 50
 
51
-    /**
52
-     * Get requested extensions.
53
-     *
54
-     * @return Extensions
55
-     */
56
-    public function extensions(): Extensions
57
-    {
58
-        return $this->_extensions;
59
-    }
51
+	/**
52
+	 * Get requested extensions.
53
+	 *
54
+	 * @return Extensions
55
+	 */
56
+	public function extensions(): Extensions
57
+	{
58
+		return $this->_extensions;
59
+	}
60 60
 
61
-    /**
62
-     * {@inheritdoc}
63
-     */
64
-    public function toASN1(): Element
65
-    {
66
-        return $this->_extensions->toASN1();
67
-    }
61
+	/**
62
+	 * {@inheritdoc}
63
+	 */
64
+	public function toASN1(): Element
65
+	{
66
+		return $this->_extensions->toASN1();
67
+	}
68 68
 
69
-    /**
70
-     * {@inheritdoc}
71
-     */
72
-    public function stringValue(): string
73
-    {
74
-        return '#' . bin2hex($this->toASN1()->toDER());
75
-    }
69
+	/**
70
+	 * {@inheritdoc}
71
+	 */
72
+	public function stringValue(): string
73
+	{
74
+		return '#' . bin2hex($this->toASN1()->toDER());
75
+	}
76 76
 
77
-    /**
78
-     * {@inheritdoc}
79
-     */
80
-    public function equalityMatchingRule(): MatchingRule
81
-    {
82
-        return new BinaryMatch();
83
-    }
77
+	/**
78
+	 * {@inheritdoc}
79
+	 */
80
+	public function equalityMatchingRule(): MatchingRule
81
+	{
82
+		return new BinaryMatch();
83
+	}
84 84
 
85
-    /**
86
-     * {@inheritdoc}
87
-     */
88
-    public function rfc2253String(): string
89
-    {
90
-        return $this->stringValue();
91
-    }
85
+	/**
86
+	 * {@inheritdoc}
87
+	 */
88
+	public function rfc2253String(): string
89
+	{
90
+		return $this->stringValue();
91
+	}
92 92
 
93
-    /**
94
-     * {@inheritdoc}
95
-     */
96
-    protected function _transcodedString(): string
97
-    {
98
-        return $this->stringValue();
99
-    }
93
+	/**
94
+	 * {@inheritdoc}
95
+	 */
96
+	protected function _transcodedString(): string
97
+	{
98
+		return $this->stringValue();
99
+	}
100 100
 }
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\X509\CertificationRequest\Attribute;
6 6
 
Please login to merge, or discard this patch.
lib/X509/CertificationRequest/Attributes.php 2 patches
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -20,108 +20,108 @@
 block discarded – undo
20 20
  */
21 21
 class Attributes implements \Countable, \IteratorAggregate
22 22
 {
23
-    use AttributeContainer;
23
+	use AttributeContainer;
24 24
 
25
-    /**
26
-     * Mapping from OID to attribute value class name.
27
-     *
28
-     * @internal
29
-     *
30
-     * @var array
31
-     */
32
-    const MAP_OID_TO_CLASS = [
33
-        ExtensionRequestValue::OID => ExtensionRequestValue::class,
34
-    ];
25
+	/**
26
+	 * Mapping from OID to attribute value class name.
27
+	 *
28
+	 * @internal
29
+	 *
30
+	 * @var array
31
+	 */
32
+	const MAP_OID_TO_CLASS = [
33
+		ExtensionRequestValue::OID => ExtensionRequestValue::class,
34
+	];
35 35
 
36
-    /**
37
-     * Constructor.
38
-     *
39
-     * @param Attribute ...$attribs Attribute objects
40
-     */
41
-    public function __construct(Attribute ...$attribs)
42
-    {
43
-        $this->_attributes = $attribs;
44
-    }
36
+	/**
37
+	 * Constructor.
38
+	 *
39
+	 * @param Attribute ...$attribs Attribute objects
40
+	 */
41
+	public function __construct(Attribute ...$attribs)
42
+	{
43
+		$this->_attributes = $attribs;
44
+	}
45 45
 
46
-    /**
47
-     * Initialize from attribute values.
48
-     *
49
-     * @param AttributeValue ...$values
50
-     *
51
-     * @return self
52
-     */
53
-    public static function fromAttributeValues(AttributeValue ...$values): Attributes
54
-    {
55
-        $attribs = array_map(
56
-            function (AttributeValue $value) {
57
-                return $value->toAttribute();
58
-            }, $values);
59
-        return new self(...$attribs);
60
-    }
46
+	/**
47
+	 * Initialize from attribute values.
48
+	 *
49
+	 * @param AttributeValue ...$values
50
+	 *
51
+	 * @return self
52
+	 */
53
+	public static function fromAttributeValues(AttributeValue ...$values): Attributes
54
+	{
55
+		$attribs = array_map(
56
+			function (AttributeValue $value) {
57
+				return $value->toAttribute();
58
+			}, $values);
59
+		return new self(...$attribs);
60
+	}
61 61
 
62
-    /**
63
-     * Initialize from ASN.1.
64
-     *
65
-     * @param Set $set
66
-     *
67
-     * @return self
68
-     */
69
-    public static function fromASN1(Set $set): Attributes
70
-    {
71
-        $attribs = array_map(
72
-            function (UnspecifiedType $el) {
73
-                return Attribute::fromASN1($el->asSequence());
74
-            }, $set->elements());
75
-        // cast attributes
76
-        $attribs = array_map(
77
-            function (Attribute $attr) {
78
-                $oid = $attr->oid();
79
-                if (array_key_exists($oid, self::MAP_OID_TO_CLASS)) {
80
-                    $cls = self::MAP_OID_TO_CLASS[$oid];
81
-                    return $attr->castValues($cls);
82
-                }
83
-                return $attr;
84
-            }, $attribs);
85
-        return new self(...$attribs);
86
-    }
62
+	/**
63
+	 * Initialize from ASN.1.
64
+	 *
65
+	 * @param Set $set
66
+	 *
67
+	 * @return self
68
+	 */
69
+	public static function fromASN1(Set $set): Attributes
70
+	{
71
+		$attribs = array_map(
72
+			function (UnspecifiedType $el) {
73
+				return Attribute::fromASN1($el->asSequence());
74
+			}, $set->elements());
75
+		// cast attributes
76
+		$attribs = array_map(
77
+			function (Attribute $attr) {
78
+				$oid = $attr->oid();
79
+				if (array_key_exists($oid, self::MAP_OID_TO_CLASS)) {
80
+					$cls = self::MAP_OID_TO_CLASS[$oid];
81
+					return $attr->castValues($cls);
82
+				}
83
+				return $attr;
84
+			}, $attribs);
85
+		return new self(...$attribs);
86
+	}
87 87
 
88
-    /**
89
-     * Check whether extension request attribute is present.
90
-     *
91
-     * @return bool
92
-     */
93
-    public function hasExtensionRequest(): bool
94
-    {
95
-        return $this->has(ExtensionRequestValue::OID);
96
-    }
88
+	/**
89
+	 * Check whether extension request attribute is present.
90
+	 *
91
+	 * @return bool
92
+	 */
93
+	public function hasExtensionRequest(): bool
94
+	{
95
+		return $this->has(ExtensionRequestValue::OID);
96
+	}
97 97
 
98
-    /**
99
-     * Get extension request attribute value.
100
-     *
101
-     * @throws \LogicException
102
-     *
103
-     * @return ExtensionRequestValue
104
-     */
105
-    public function extensionRequest(): ExtensionRequestValue
106
-    {
107
-        if (!$this->hasExtensionRequest()) {
108
-            throw new \LogicException('No extension request attribute.');
109
-        }
110
-        return $this->firstOf(ExtensionRequestValue::OID)->first();
111
-    }
98
+	/**
99
+	 * Get extension request attribute value.
100
+	 *
101
+	 * @throws \LogicException
102
+	 *
103
+	 * @return ExtensionRequestValue
104
+	 */
105
+	public function extensionRequest(): ExtensionRequestValue
106
+	{
107
+		if (!$this->hasExtensionRequest()) {
108
+			throw new \LogicException('No extension request attribute.');
109
+		}
110
+		return $this->firstOf(ExtensionRequestValue::OID)->first();
111
+	}
112 112
 
113
-    /**
114
-     * Generate ASN.1 structure.
115
-     *
116
-     * @return Set
117
-     */
118
-    public function toASN1(): Set
119
-    {
120
-        $elements = array_map(
121
-            function (Attribute $attr) {
122
-                return $attr->toASN1();
123
-            }, array_values($this->_attributes));
124
-        $set = new Set(...$elements);
125
-        return $set->sortedSetOf();
126
-    }
113
+	/**
114
+	 * Generate ASN.1 structure.
115
+	 *
116
+	 * @return Set
117
+	 */
118
+	public function toASN1(): Set
119
+	{
120
+		$elements = array_map(
121
+			function (Attribute $attr) {
122
+				return $attr->toASN1();
123
+			}, array_values($this->_attributes));
124
+		$set = new Set(...$elements);
125
+		return $set->sortedSetOf();
126
+	}
127 127
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X509\CertificationRequest;
6 6
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     public static function fromAttributeValues(AttributeValue ...$values): Attributes
54 54
     {
55 55
         $attribs = array_map(
56
-            function (AttributeValue $value) {
56
+            function(AttributeValue $value) {
57 57
                 return $value->toAttribute();
58 58
             }, $values);
59 59
         return new self(...$attribs);
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
     public static function fromASN1(Set $set): Attributes
70 70
     {
71 71
         $attribs = array_map(
72
-            function (UnspecifiedType $el) {
72
+            function(UnspecifiedType $el) {
73 73
                 return Attribute::fromASN1($el->asSequence());
74 74
             }, $set->elements());
75 75
         // cast attributes
76 76
         $attribs = array_map(
77
-            function (Attribute $attr) {
77
+            function(Attribute $attr) {
78 78
                 $oid = $attr->oid();
79 79
                 if (array_key_exists($oid, self::MAP_OID_TO_CLASS)) {
80 80
                     $cls = self::MAP_OID_TO_CLASS[$oid];
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
     public function toASN1(): Set
119 119
     {
120 120
         $elements = array_map(
121
-            function (Attribute $attr) {
121
+            function(Attribute $attr) {
122 122
                 return $attr->toASN1();
123 123
             }, array_values($this->_attributes));
124 124
         $set = new Set(...$elements);
Please login to merge, or discard this patch.