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.
Completed
Push — master ( da62d3...8abb02 )
by Joni
02:44
created
lib/X509/Certificate/Extension/DistributionPoint/DistributionPoint.php 1 patch
Indentation   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -18,215 +18,215 @@
 block discarded – undo
18 18
  */
19 19
 class DistributionPoint
20 20
 {
21
-    /**
22
-     * Distribution point name.
23
-     *
24
-     * @var DistributionPointName $_distributionPoint
25
-     */
26
-    protected $_distributionPoint;
21
+	/**
22
+	 * Distribution point name.
23
+	 *
24
+	 * @var DistributionPointName $_distributionPoint
25
+	 */
26
+	protected $_distributionPoint;
27 27
     
28
-    /**
29
-     * Revocation reason.
30
-     *
31
-     * @var ReasonFlags $_reasons
32
-     */
33
-    protected $_reasons;
28
+	/**
29
+	 * Revocation reason.
30
+	 *
31
+	 * @var ReasonFlags $_reasons
32
+	 */
33
+	protected $_reasons;
34 34
     
35
-    /**
36
-     * CRL issuer.
37
-     *
38
-     * @var GeneralNames $_issuer
39
-     */
40
-    protected $_issuer;
35
+	/**
36
+	 * CRL issuer.
37
+	 *
38
+	 * @var GeneralNames $_issuer
39
+	 */
40
+	protected $_issuer;
41 41
     
42
-    /**
43
-     * Constructor.
44
-     *
45
-     * @param DistributionPointName $name
46
-     * @param ReasonFlags $reasons
47
-     * @param GeneralNames $issuer
48
-     */
49
-    public function __construct(DistributionPointName $name = null,
50
-        ReasonFlags $reasons = null, GeneralNames $issuer = null)
51
-    {
52
-        $this->_distributionPoint = $name;
53
-        $this->_reasons = $reasons;
54
-        $this->_issuer = $issuer;
55
-    }
42
+	/**
43
+	 * Constructor.
44
+	 *
45
+	 * @param DistributionPointName $name
46
+	 * @param ReasonFlags $reasons
47
+	 * @param GeneralNames $issuer
48
+	 */
49
+	public function __construct(DistributionPointName $name = null,
50
+		ReasonFlags $reasons = null, GeneralNames $issuer = null)
51
+	{
52
+		$this->_distributionPoint = $name;
53
+		$this->_reasons = $reasons;
54
+		$this->_issuer = $issuer;
55
+	}
56 56
     
57
-    /**
58
-     * Initialize from ASN.1.
59
-     *
60
-     * @param Sequence $seq
61
-     * @return self
62
-     */
63
-    public static function fromASN1(Sequence $seq): self
64
-    {
65
-        $name = null;
66
-        $reasons = null;
67
-        $issuer = null;
68
-        if ($seq->hasTagged(0)) {
69
-            // promoted to explicit tagging because underlying type is CHOICE
70
-            $name = DistributionPointName::fromTaggedType(
71
-                $seq->getTagged(0)
72
-                    ->asExplicit()
73
-                    ->asTagged());
74
-        }
75
-        if ($seq->hasTagged(1)) {
76
-            $reasons = ReasonFlags::fromASN1(
77
-                $seq->getTagged(1)
78
-                    ->asImplicit(Element::TYPE_BIT_STRING)
79
-                    ->asBitString());
80
-        }
81
-        if ($seq->hasTagged(2)) {
82
-            $issuer = GeneralNames::fromASN1(
83
-                $seq->getTagged(2)
84
-                    ->asImplicit(Element::TYPE_SEQUENCE)
85
-                    ->asSequence());
86
-        }
87
-        return new self($name, $reasons, $issuer);
88
-    }
57
+	/**
58
+	 * Initialize from ASN.1.
59
+	 *
60
+	 * @param Sequence $seq
61
+	 * @return self
62
+	 */
63
+	public static function fromASN1(Sequence $seq): self
64
+	{
65
+		$name = null;
66
+		$reasons = null;
67
+		$issuer = null;
68
+		if ($seq->hasTagged(0)) {
69
+			// promoted to explicit tagging because underlying type is CHOICE
70
+			$name = DistributionPointName::fromTaggedType(
71
+				$seq->getTagged(0)
72
+					->asExplicit()
73
+					->asTagged());
74
+		}
75
+		if ($seq->hasTagged(1)) {
76
+			$reasons = ReasonFlags::fromASN1(
77
+				$seq->getTagged(1)
78
+					->asImplicit(Element::TYPE_BIT_STRING)
79
+					->asBitString());
80
+		}
81
+		if ($seq->hasTagged(2)) {
82
+			$issuer = GeneralNames::fromASN1(
83
+				$seq->getTagged(2)
84
+					->asImplicit(Element::TYPE_SEQUENCE)
85
+					->asSequence());
86
+		}
87
+		return new self($name, $reasons, $issuer);
88
+	}
89 89
     
90
-    /**
91
-     * Check whether distribution point name is set.
92
-     *
93
-     * @return bool
94
-     */
95
-    public function hasDistributionPointName(): bool
96
-    {
97
-        return isset($this->_distributionPoint);
98
-    }
90
+	/**
91
+	 * Check whether distribution point name is set.
92
+	 *
93
+	 * @return bool
94
+	 */
95
+	public function hasDistributionPointName(): bool
96
+	{
97
+		return isset($this->_distributionPoint);
98
+	}
99 99
     
100
-    /**
101
-     * Get distribution point name.
102
-     *
103
-     * @throws \LogicException
104
-     * @return DistributionPointName
105
-     */
106
-    public function distributionPointName(): DistributionPointName
107
-    {
108
-        if (!$this->hasDistributionPointName()) {
109
-            throw new \LogicException("distributionPoint not set.");
110
-        }
111
-        return $this->_distributionPoint;
112
-    }
100
+	/**
101
+	 * Get distribution point name.
102
+	 *
103
+	 * @throws \LogicException
104
+	 * @return DistributionPointName
105
+	 */
106
+	public function distributionPointName(): DistributionPointName
107
+	{
108
+		if (!$this->hasDistributionPointName()) {
109
+			throw new \LogicException("distributionPoint not set.");
110
+		}
111
+		return $this->_distributionPoint;
112
+	}
113 113
     
114
-    /**
115
-     * Check whether distribution point name is set and it's a full name.
116
-     *
117
-     * @return bool
118
-     */
119
-    public function hasFullName(): bool
120
-    {
121
-        return $this->distributionPointName()->tag() ==
122
-             DistributionPointName::TAG_FULL_NAME;
123
-    }
114
+	/**
115
+	 * Check whether distribution point name is set and it's a full name.
116
+	 *
117
+	 * @return bool
118
+	 */
119
+	public function hasFullName(): bool
120
+	{
121
+		return $this->distributionPointName()->tag() ==
122
+			 DistributionPointName::TAG_FULL_NAME;
123
+	}
124 124
     
125
-    /**
126
-     * Get full distribution point name.
127
-     *
128
-     * @throws \LogicException
129
-     * @return FullName
130
-     */
131
-    public function fullName(): FullName
132
-    {
133
-        if (!$this->hasFullName()) {
134
-            throw new \LogicException("fullName not set.");
135
-        }
136
-        return $this->_distributionPoint;
137
-    }
125
+	/**
126
+	 * Get full distribution point name.
127
+	 *
128
+	 * @throws \LogicException
129
+	 * @return FullName
130
+	 */
131
+	public function fullName(): FullName
132
+	{
133
+		if (!$this->hasFullName()) {
134
+			throw new \LogicException("fullName not set.");
135
+		}
136
+		return $this->_distributionPoint;
137
+	}
138 138
     
139
-    /**
140
-     * Check whether distribution point name is set and it's a relative name.
141
-     *
142
-     * @return bool
143
-     */
144
-    public function hasRelativeName(): bool
145
-    {
146
-        return $this->distributionPointName()->tag() ==
147
-             DistributionPointName::TAG_RDN;
148
-    }
139
+	/**
140
+	 * Check whether distribution point name is set and it's a relative name.
141
+	 *
142
+	 * @return bool
143
+	 */
144
+	public function hasRelativeName(): bool
145
+	{
146
+		return $this->distributionPointName()->tag() ==
147
+			 DistributionPointName::TAG_RDN;
148
+	}
149 149
     
150
-    /**
151
-     * Get relative distribution point name.
152
-     *
153
-     * @throws \LogicException
154
-     * @return RelativeName
155
-     */
156
-    public function relativeName(): RelativeName
157
-    {
158
-        if (!$this->hasRelativeName()) {
159
-            throw new \LogicException("nameRelativeToCRLIssuer not set.");
160
-        }
161
-        return $this->_distributionPoint;
162
-    }
150
+	/**
151
+	 * Get relative distribution point name.
152
+	 *
153
+	 * @throws \LogicException
154
+	 * @return RelativeName
155
+	 */
156
+	public function relativeName(): RelativeName
157
+	{
158
+		if (!$this->hasRelativeName()) {
159
+			throw new \LogicException("nameRelativeToCRLIssuer not set.");
160
+		}
161
+		return $this->_distributionPoint;
162
+	}
163 163
     
164
-    /**
165
-     * Check whether reasons flags is set.
166
-     *
167
-     * @return bool
168
-     */
169
-    public function hasReasons(): bool
170
-    {
171
-        return isset($this->_reasons);
172
-    }
164
+	/**
165
+	 * Check whether reasons flags is set.
166
+	 *
167
+	 * @return bool
168
+	 */
169
+	public function hasReasons(): bool
170
+	{
171
+		return isset($this->_reasons);
172
+	}
173 173
     
174
-    /**
175
-     * Get revocation reason flags.
176
-     *
177
-     * @throws \LogicException
178
-     * @return ReasonFlags
179
-     */
180
-    public function reasons(): ReasonFlags
181
-    {
182
-        if (!$this->hasReasons()) {
183
-            throw new \LogicException("reasons not set.");
184
-        }
185
-        return $this->_reasons;
186
-    }
174
+	/**
175
+	 * Get revocation reason flags.
176
+	 *
177
+	 * @throws \LogicException
178
+	 * @return ReasonFlags
179
+	 */
180
+	public function reasons(): ReasonFlags
181
+	{
182
+		if (!$this->hasReasons()) {
183
+			throw new \LogicException("reasons not set.");
184
+		}
185
+		return $this->_reasons;
186
+	}
187 187
     
188
-    /**
189
-     * Check whether cRLIssuer is set.
190
-     *
191
-     * @return bool
192
-     */
193
-    public function hasCRLIssuer(): bool
194
-    {
195
-        return isset($this->_issuer);
196
-    }
188
+	/**
189
+	 * Check whether cRLIssuer is set.
190
+	 *
191
+	 * @return bool
192
+	 */
193
+	public function hasCRLIssuer(): bool
194
+	{
195
+		return isset($this->_issuer);
196
+	}
197 197
     
198
-    /**
199
-     * Get CRL issuer.
200
-     *
201
-     * @throws \LogicException
202
-     * @return GeneralNames
203
-     */
204
-    public function crlIssuer(): GeneralNames
205
-    {
206
-        if (!$this->hasCRLIssuer()) {
207
-            throw new \LogicException("crlIssuer not set.");
208
-        }
209
-        return $this->_issuer;
210
-    }
198
+	/**
199
+	 * Get CRL issuer.
200
+	 *
201
+	 * @throws \LogicException
202
+	 * @return GeneralNames
203
+	 */
204
+	public function crlIssuer(): GeneralNames
205
+	{
206
+		if (!$this->hasCRLIssuer()) {
207
+			throw new \LogicException("crlIssuer not set.");
208
+		}
209
+		return $this->_issuer;
210
+	}
211 211
     
212
-    /**
213
-     * Generate ASN.1 structure.
214
-     *
215
-     * @return Sequence
216
-     */
217
-    public function toASN1(): Sequence
218
-    {
219
-        $elements = array();
220
-        if (isset($this->_distributionPoint)) {
221
-            $elements[] = new ExplicitlyTaggedType(0,
222
-                $this->_distributionPoint->toASN1());
223
-        }
224
-        if (isset($this->_reasons)) {
225
-            $elements[] = new ImplicitlyTaggedType(1, $this->_reasons->toASN1());
226
-        }
227
-        if (isset($this->_issuer)) {
228
-            $elements[] = new ImplicitlyTaggedType(2, $this->_issuer->toASN1());
229
-        }
230
-        return new Sequence(...$elements);
231
-    }
212
+	/**
213
+	 * Generate ASN.1 structure.
214
+	 *
215
+	 * @return Sequence
216
+	 */
217
+	public function toASN1(): Sequence
218
+	{
219
+		$elements = array();
220
+		if (isset($this->_distributionPoint)) {
221
+			$elements[] = new ExplicitlyTaggedType(0,
222
+				$this->_distributionPoint->toASN1());
223
+		}
224
+		if (isset($this->_reasons)) {
225
+			$elements[] = new ImplicitlyTaggedType(1, $this->_reasons->toASN1());
226
+		}
227
+		if (isset($this->_issuer)) {
228
+			$elements[] = new ImplicitlyTaggedType(2, $this->_issuer->toASN1());
229
+		}
230
+		return new Sequence(...$elements);
231
+	}
232 232
 }
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/BasicConstraintsExtension.php 1 patch
Indentation   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -16,106 +16,106 @@
 block discarded – undo
16 16
  */
17 17
 class BasicConstraintsExtension extends Extension
18 18
 {
19
-    /**
20
-     * Whether certificate is a CA.
21
-     *
22
-     * @var boolean $_ca
23
-     */
24
-    protected $_ca;
19
+	/**
20
+	 * Whether certificate is a CA.
21
+	 *
22
+	 * @var boolean $_ca
23
+	 */
24
+	protected $_ca;
25 25
     
26
-    /**
27
-     * Maximum certification path length.
28
-     *
29
-     * @var int|null $_pathLen
30
-     */
31
-    protected $_pathLen;
26
+	/**
27
+	 * Maximum certification path length.
28
+	 *
29
+	 * @var int|null $_pathLen
30
+	 */
31
+	protected $_pathLen;
32 32
     
33
-    /**
34
-     * Constructor.
35
-     *
36
-     * @param bool $critical
37
-     * @param bool $ca
38
-     * @param int|null $path_len
39
-     */
40
-    public function __construct(bool $critical, bool $ca, $path_len = null)
41
-    {
42
-        parent::__construct(self::OID_BASIC_CONSTRAINTS, $critical);
43
-        $this->_ca = $ca;
44
-        $this->_pathLen = isset($path_len) ? intval($path_len) : null;
45
-    }
33
+	/**
34
+	 * Constructor.
35
+	 *
36
+	 * @param bool $critical
37
+	 * @param bool $ca
38
+	 * @param int|null $path_len
39
+	 */
40
+	public function __construct(bool $critical, bool $ca, $path_len = null)
41
+	{
42
+		parent::__construct(self::OID_BASIC_CONSTRAINTS, $critical);
43
+		$this->_ca = $ca;
44
+		$this->_pathLen = isset($path_len) ? intval($path_len) : null;
45
+	}
46 46
     
47
-    /**
48
-     *
49
-     * {@inheritdoc}
50
-     * @return self
51
-     */
52
-    protected static function _fromDER(string $data, bool $critical): self
53
-    {
54
-        $seq = Sequence::fromDER($data);
55
-        $ca = false;
56
-        $path_len = null;
57
-        $idx = 0;
58
-        if ($seq->has($idx, Element::TYPE_BOOLEAN)) {
59
-            $ca = $seq->at($idx++)
60
-                ->asBoolean()
61
-                ->value();
62
-        }
63
-        if ($seq->has($idx, Element::TYPE_INTEGER)) {
64
-            $path_len = $seq->at($idx)
65
-                ->asInteger()
66
-                ->intNumber();
67
-        }
68
-        return new self($critical, $ca, $path_len);
69
-    }
47
+	/**
48
+	 *
49
+	 * {@inheritdoc}
50
+	 * @return self
51
+	 */
52
+	protected static function _fromDER(string $data, bool $critical): self
53
+	{
54
+		$seq = Sequence::fromDER($data);
55
+		$ca = false;
56
+		$path_len = null;
57
+		$idx = 0;
58
+		if ($seq->has($idx, Element::TYPE_BOOLEAN)) {
59
+			$ca = $seq->at($idx++)
60
+				->asBoolean()
61
+				->value();
62
+		}
63
+		if ($seq->has($idx, Element::TYPE_INTEGER)) {
64
+			$path_len = $seq->at($idx)
65
+				->asInteger()
66
+				->intNumber();
67
+		}
68
+		return new self($critical, $ca, $path_len);
69
+	}
70 70
     
71
-    /**
72
-     * Whether certificate is a CA.
73
-     *
74
-     * @return bool
75
-     */
76
-    public function isCA(): bool
77
-    {
78
-        return $this->_ca;
79
-    }
71
+	/**
72
+	 * Whether certificate is a CA.
73
+	 *
74
+	 * @return bool
75
+	 */
76
+	public function isCA(): bool
77
+	{
78
+		return $this->_ca;
79
+	}
80 80
     
81
-    /**
82
-     * Whether path length is present.
83
-     *
84
-     * @return bool
85
-     */
86
-    public function hasPathLen(): bool
87
-    {
88
-        return isset($this->_pathLen);
89
-    }
81
+	/**
82
+	 * Whether path length is present.
83
+	 *
84
+	 * @return bool
85
+	 */
86
+	public function hasPathLen(): bool
87
+	{
88
+		return isset($this->_pathLen);
89
+	}
90 90
     
91
-    /**
92
-     * Get path length.
93
-     *
94
-     * @throws \LogicException
95
-     * @return int
96
-     */
97
-    public function pathLen(): int
98
-    {
99
-        if (!$this->hasPathLen()) {
100
-            throw new \LogicException("pathLenConstraint not set.");
101
-        }
102
-        return $this->_pathLen;
103
-    }
91
+	/**
92
+	 * Get path length.
93
+	 *
94
+	 * @throws \LogicException
95
+	 * @return int
96
+	 */
97
+	public function pathLen(): int
98
+	{
99
+		if (!$this->hasPathLen()) {
100
+			throw new \LogicException("pathLenConstraint not set.");
101
+		}
102
+		return $this->_pathLen;
103
+	}
104 104
     
105
-    /**
106
-     *
107
-     * {@inheritdoc}
108
-     * @return Sequence
109
-     */
110
-    protected function _valueASN1(): Sequence
111
-    {
112
-        $elements = array();
113
-        if ($this->_ca) {
114
-            $elements[] = new Boolean(true);
115
-        }
116
-        if (isset($this->_pathLen)) {
117
-            $elements[] = new Integer($this->_pathLen);
118
-        }
119
-        return new Sequence(...$elements);
120
-    }
105
+	/**
106
+	 *
107
+	 * {@inheritdoc}
108
+	 * @return Sequence
109
+	 */
110
+	protected function _valueASN1(): Sequence
111
+	{
112
+		$elements = array();
113
+		if ($this->_ca) {
114
+			$elements[] = new Boolean(true);
115
+		}
116
+		if (isset($this->_pathLen)) {
117
+			$elements[] = new Integer($this->_pathLen);
118
+		}
119
+		return new Sequence(...$elements);
120
+	}
121 121
 }
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/NameConstraintsExtension.php 1 patch
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -16,122 +16,122 @@
 block discarded – undo
16 16
  */
17 17
 class NameConstraintsExtension extends Extension
18 18
 {
19
-    /**
20
-     * Permitted subtrees.
21
-     *
22
-     * @var GeneralSubtrees|null $_permitted
23
-     */
24
-    protected $_permitted;
19
+	/**
20
+	 * Permitted subtrees.
21
+	 *
22
+	 * @var GeneralSubtrees|null $_permitted
23
+	 */
24
+	protected $_permitted;
25 25
     
26
-    /**
27
-     * Excluded subtrees.
28
-     *
29
-     * @var GeneralSubtrees|null $_excluded
30
-     */
31
-    protected $_excluded;
26
+	/**
27
+	 * Excluded subtrees.
28
+	 *
29
+	 * @var GeneralSubtrees|null $_excluded
30
+	 */
31
+	protected $_excluded;
32 32
     
33
-    /**
34
-     * Constructor.
35
-     *
36
-     * @param bool $critical
37
-     * @param GeneralSubtrees $permitted
38
-     * @param GeneralSubtrees $excluded
39
-     */
40
-    public function __construct(bool $critical, GeneralSubtrees $permitted = null,
41
-        GeneralSubtrees $excluded = null)
42
-    {
43
-        parent::__construct(self::OID_NAME_CONSTRAINTS, $critical);
44
-        $this->_permitted = $permitted;
45
-        $this->_excluded = $excluded;
46
-    }
33
+	/**
34
+	 * Constructor.
35
+	 *
36
+	 * @param bool $critical
37
+	 * @param GeneralSubtrees $permitted
38
+	 * @param GeneralSubtrees $excluded
39
+	 */
40
+	public function __construct(bool $critical, GeneralSubtrees $permitted = null,
41
+		GeneralSubtrees $excluded = null)
42
+	{
43
+		parent::__construct(self::OID_NAME_CONSTRAINTS, $critical);
44
+		$this->_permitted = $permitted;
45
+		$this->_excluded = $excluded;
46
+	}
47 47
     
48
-    /**
49
-     *
50
-     * {@inheritdoc}
51
-     * @return self
52
-     */
53
-    protected static function _fromDER(string $data, bool $critical): self
54
-    {
55
-        $seq = Sequence::fromDER($data);
56
-        $permitted = null;
57
-        $excluded = null;
58
-        if ($seq->hasTagged(0)) {
59
-            $permitted = GeneralSubtrees::fromASN1(
60
-                $seq->getTagged(0)
61
-                    ->asImplicit(Element::TYPE_SEQUENCE)
62
-                    ->asSequence());
63
-        }
64
-        if ($seq->hasTagged(1)) {
65
-            $excluded = GeneralSubtrees::fromASN1(
66
-                $seq->getTagged(1)
67
-                    ->asImplicit(Element::TYPE_SEQUENCE)
68
-                    ->asSequence());
69
-        }
70
-        return new self($critical, $permitted, $excluded);
71
-    }
48
+	/**
49
+	 *
50
+	 * {@inheritdoc}
51
+	 * @return self
52
+	 */
53
+	protected static function _fromDER(string $data, bool $critical): self
54
+	{
55
+		$seq = Sequence::fromDER($data);
56
+		$permitted = null;
57
+		$excluded = null;
58
+		if ($seq->hasTagged(0)) {
59
+			$permitted = GeneralSubtrees::fromASN1(
60
+				$seq->getTagged(0)
61
+					->asImplicit(Element::TYPE_SEQUENCE)
62
+					->asSequence());
63
+		}
64
+		if ($seq->hasTagged(1)) {
65
+			$excluded = GeneralSubtrees::fromASN1(
66
+				$seq->getTagged(1)
67
+					->asImplicit(Element::TYPE_SEQUENCE)
68
+					->asSequence());
69
+		}
70
+		return new self($critical, $permitted, $excluded);
71
+	}
72 72
     
73
-    /**
74
-     * Whether permitted subtrees are present.
75
-     *
76
-     * @return bool
77
-     */
78
-    public function hasPermittedSubtrees(): bool
79
-    {
80
-        return isset($this->_permitted);
81
-    }
73
+	/**
74
+	 * Whether permitted subtrees are present.
75
+	 *
76
+	 * @return bool
77
+	 */
78
+	public function hasPermittedSubtrees(): bool
79
+	{
80
+		return isset($this->_permitted);
81
+	}
82 82
     
83
-    /**
84
-     * Get permitted subtrees.
85
-     *
86
-     * @throws \LogicException
87
-     * @return GeneralSubtrees
88
-     */
89
-    public function permittedSubtrees(): GeneralSubtrees
90
-    {
91
-        if (!$this->hasPermittedSubtrees()) {
92
-            throw new \LogicException("No permitted subtrees.");
93
-        }
94
-        return $this->_permitted;
95
-    }
83
+	/**
84
+	 * Get permitted subtrees.
85
+	 *
86
+	 * @throws \LogicException
87
+	 * @return GeneralSubtrees
88
+	 */
89
+	public function permittedSubtrees(): GeneralSubtrees
90
+	{
91
+		if (!$this->hasPermittedSubtrees()) {
92
+			throw new \LogicException("No permitted subtrees.");
93
+		}
94
+		return $this->_permitted;
95
+	}
96 96
     
97
-    /**
98
-     * Whether excluded subtrees are present.
99
-     *
100
-     * @return bool
101
-     */
102
-    public function hasExcludedSubtrees(): bool
103
-    {
104
-        return isset($this->_excluded);
105
-    }
97
+	/**
98
+	 * Whether excluded subtrees are present.
99
+	 *
100
+	 * @return bool
101
+	 */
102
+	public function hasExcludedSubtrees(): bool
103
+	{
104
+		return isset($this->_excluded);
105
+	}
106 106
     
107
-    /**
108
-     * Get excluded subtrees.
109
-     *
110
-     * @throws \LogicException
111
-     * @return GeneralSubtrees
112
-     */
113
-    public function excludedSubtrees(): GeneralSubtrees
114
-    {
115
-        if (!$this->hasExcludedSubtrees()) {
116
-            throw new \LogicException("No excluded subtrees.");
117
-        }
118
-        return $this->_excluded;
119
-    }
107
+	/**
108
+	 * Get excluded subtrees.
109
+	 *
110
+	 * @throws \LogicException
111
+	 * @return GeneralSubtrees
112
+	 */
113
+	public function excludedSubtrees(): GeneralSubtrees
114
+	{
115
+		if (!$this->hasExcludedSubtrees()) {
116
+			throw new \LogicException("No excluded subtrees.");
117
+		}
118
+		return $this->_excluded;
119
+	}
120 120
     
121
-    /**
122
-     *
123
-     * {@inheritdoc}
124
-     * @return Sequence
125
-     */
126
-    protected function _valueASN1(): Sequence
127
-    {
128
-        $elements = array();
129
-        if (isset($this->_permitted)) {
130
-            $elements[] = new ImplicitlyTaggedType(0, $this->_permitted->toASN1());
131
-        }
132
-        if (isset($this->_excluded)) {
133
-            $elements[] = new ImplicitlyTaggedType(1, $this->_excluded->toASN1());
134
-        }
135
-        return new Sequence(...$elements);
136
-    }
121
+	/**
122
+	 *
123
+	 * {@inheritdoc}
124
+	 * @return Sequence
125
+	 */
126
+	protected function _valueASN1(): Sequence
127
+	{
128
+		$elements = array();
129
+		if (isset($this->_permitted)) {
130
+			$elements[] = new ImplicitlyTaggedType(0, $this->_permitted->toASN1());
131
+		}
132
+		if (isset($this->_excluded)) {
133
+			$elements[] = new ImplicitlyTaggedType(1, $this->_excluded->toASN1());
134
+		}
135
+		return new Sequence(...$elements);
136
+	}
137 137
 }
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/Extension.php 1 patch
Indentation   +199 added lines, -199 removed lines patch added patch discarded remove patch
@@ -19,214 +19,214 @@
 block discarded – undo
19 19
  */
20 20
 abstract class Extension
21 21
 {
22
-    // OID's from standard certificate extensions
23
-    const OID_OBSOLETE_AUTHORITY_KEY_IDENTIFIER = "2.5.29.1";
24
-    const OID_OBSOLETE_KEY_ATTRIBUTES = "2.5.29.2";
25
-    const OID_OBSOLETE_CERTIFICATE_POLICIES = "2.5.29.3";
26
-    const OID_OBSOLETE_KEY_USAGE_RESTRICTION = "2.5.29.4";
27
-    const OID_OBSOLETE_POLICY_MAPPING = "2.5.29.5";
28
-    const OID_OBSOLETE_SUBTREES_CONSTRAINT = "2.5.29.6";
29
-    const OID_OBSOLETE_SUBJECT_ALT_NAME = "2.5.29.7";
30
-    const OID_OBSOLETE_ISSUER_ALT_NAME = "2.5.29.8";
31
-    const OID_SUBJECT_DIRECTORY_ATTRIBUTES = "2.5.29.9";
32
-    const OID_OBSOLETE_BASIC_CONSTRAINTS = "2.5.29.10";
33
-    const OID_SUBJECT_KEY_IDENTIFIER = "2.5.29.14";
34
-    const OID_KEY_USAGE = "2.5.29.15";
35
-    const OID_PRIVATE_KEY_USAGE_PERIOD = "2.5.29.16";
36
-    const OID_SUBJECT_ALT_NAME = "2.5.29.17";
37
-    const OID_ISSUER_ALT_NAME = "2.5.29.18";
38
-    const OID_BASIC_CONSTRAINTS = "2.5.29.19";
39
-    const OID_CRL_NUMBER = "2.5.29.20";
40
-    const OID_REASON_CODE = "2.5.29.21";
41
-    const OID_OBSOLETE_EXPIRATION_DATE = "2.5.29.22";
42
-    const OID_INSTRUCTION_CODE = "2.5.29.23";
43
-    const OID_INVALIDITY_DATE = "2.5.29.24";
44
-    const OID_OBSOLETE_CRL_DISTRIBUTION_POINTS = "2.5.29.25";
45
-    const OID_OBSOLETE_ISSUING_DISTRIBUTION_POINT = "2.5.29.26";
46
-    const OID_DELTA_CRL_INDICATOR = "2.5.29.27";
47
-    const OID_ISSUING_DISTRIBUTION_POINT = "2.5.29.28";
48
-    const OID_CERTIFICATE_ISSUER = "2.5.29.29";
49
-    const OID_NAME_CONSTRAINTS = "2.5.29.30";
50
-    const OID_CRL_DISTRIBUTION_POINTS = "2.5.29.31";
51
-    const OID_CERTIFICATE_POLICIES = "2.5.29.32";
52
-    const OID_POLICY_MAPPINGS = "2.5.29.33";
53
-    const OID_OBSOLETE_POLICY_CONSTRAINTS = "2.5.29.34";
54
-    const OID_AUTHORITY_KEY_IDENTIFIER = "2.5.29.35";
55
-    const OID_POLICY_CONSTRAINTS = "2.5.29.36";
56
-    const OID_EXT_KEY_USAGE = "2.5.29.37";
57
-    const OID_AUTHORITY_ATTRIBUTE_IDENTIFIER = "2.5.29.38";
58
-    const OID_ROLE_SPEC_CERT_IDENTIFIER = "2.5.29.39";
59
-    const OID_CRL_STREAM_IDENTIFIER = "2.5.29.40";
60
-    const OID_BASIC_ATT_CONSTRAINTS = "2.5.29.41";
61
-    const OID_DELEGATED_NAME_CONSTRAINTS = "2.5.29.42";
62
-    const OID_TIME_SPECIFICATION = "2.5.29.43";
63
-    const OID_CRL_SCOPE = "2.5.29.44";
64
-    const OID_STATUS_REFERRALS = "2.5.29.45";
65
-    const OID_FRESHEST_CRL = "2.5.29.46";
66
-    const OID_ORDERED_LIST = "2.5.29.47";
67
-    const OID_ATTRIBUTE_DESCRIPTOR = "2.5.29.48";
68
-    const OID_USER_NOTICE = "2.5.29.49";
69
-    const OID_SOA_IDENTIFIER = "2.5.29.50";
70
-    const OID_BASE_UPDATE_TIME = "2.5.29.51";
71
-    const OID_ACCEPTABLE_CERT_POLICIES = "2.5.29.52";
72
-    const OID_DELTA_INFO = "2.5.29.53";
73
-    const OID_INHIBIT_ANY_POLICY = "2.5.29.54";
74
-    const OID_TARGET_INFORMATION = "2.5.29.55";
75
-    const OID_NO_REV_AVAIL = "2.5.29.56";
76
-    const OID_ACCEPTABLE_PRIVILEGE_POLICIES = "2.5.29.57";
77
-    const OID_TO_BE_REVOKED = "2.5.29.58";
78
-    const OID_REVOKED_GROUPS = "2.5.29.59";
79
-    const OID_EXPIRED_CERTS_ON_CRL = "2.5.29.60";
80
-    const OID_INDIRECT_ISSUER = "2.5.29.61";
81
-    const OID_NO_ASSERTION = "2.5.29.62";
82
-    const OID_AA_ISSUING_DISTRIBUTION_POINT = "2.5.29.63";
83
-    const OID_ISSUED_ON_BEHALF_OF = "2.5.29.64";
84
-    const OID_SINGLE_USE = "2.5.29.65";
85
-    const OID_GROUP_AC = "2.5.29.66";
86
-    const OID_ALLOWED_ATT_ASS = "2.5.29.67";
87
-    const OID_ATTRIBUTE_MAPPINGS = "2.5.29.68";
88
-    const OID_HOLDER_NAME_CONSTRAINTS = "2.5.29.69";
22
+	// OID's from standard certificate extensions
23
+	const OID_OBSOLETE_AUTHORITY_KEY_IDENTIFIER = "2.5.29.1";
24
+	const OID_OBSOLETE_KEY_ATTRIBUTES = "2.5.29.2";
25
+	const OID_OBSOLETE_CERTIFICATE_POLICIES = "2.5.29.3";
26
+	const OID_OBSOLETE_KEY_USAGE_RESTRICTION = "2.5.29.4";
27
+	const OID_OBSOLETE_POLICY_MAPPING = "2.5.29.5";
28
+	const OID_OBSOLETE_SUBTREES_CONSTRAINT = "2.5.29.6";
29
+	const OID_OBSOLETE_SUBJECT_ALT_NAME = "2.5.29.7";
30
+	const OID_OBSOLETE_ISSUER_ALT_NAME = "2.5.29.8";
31
+	const OID_SUBJECT_DIRECTORY_ATTRIBUTES = "2.5.29.9";
32
+	const OID_OBSOLETE_BASIC_CONSTRAINTS = "2.5.29.10";
33
+	const OID_SUBJECT_KEY_IDENTIFIER = "2.5.29.14";
34
+	const OID_KEY_USAGE = "2.5.29.15";
35
+	const OID_PRIVATE_KEY_USAGE_PERIOD = "2.5.29.16";
36
+	const OID_SUBJECT_ALT_NAME = "2.5.29.17";
37
+	const OID_ISSUER_ALT_NAME = "2.5.29.18";
38
+	const OID_BASIC_CONSTRAINTS = "2.5.29.19";
39
+	const OID_CRL_NUMBER = "2.5.29.20";
40
+	const OID_REASON_CODE = "2.5.29.21";
41
+	const OID_OBSOLETE_EXPIRATION_DATE = "2.5.29.22";
42
+	const OID_INSTRUCTION_CODE = "2.5.29.23";
43
+	const OID_INVALIDITY_DATE = "2.5.29.24";
44
+	const OID_OBSOLETE_CRL_DISTRIBUTION_POINTS = "2.5.29.25";
45
+	const OID_OBSOLETE_ISSUING_DISTRIBUTION_POINT = "2.5.29.26";
46
+	const OID_DELTA_CRL_INDICATOR = "2.5.29.27";
47
+	const OID_ISSUING_DISTRIBUTION_POINT = "2.5.29.28";
48
+	const OID_CERTIFICATE_ISSUER = "2.5.29.29";
49
+	const OID_NAME_CONSTRAINTS = "2.5.29.30";
50
+	const OID_CRL_DISTRIBUTION_POINTS = "2.5.29.31";
51
+	const OID_CERTIFICATE_POLICIES = "2.5.29.32";
52
+	const OID_POLICY_MAPPINGS = "2.5.29.33";
53
+	const OID_OBSOLETE_POLICY_CONSTRAINTS = "2.5.29.34";
54
+	const OID_AUTHORITY_KEY_IDENTIFIER = "2.5.29.35";
55
+	const OID_POLICY_CONSTRAINTS = "2.5.29.36";
56
+	const OID_EXT_KEY_USAGE = "2.5.29.37";
57
+	const OID_AUTHORITY_ATTRIBUTE_IDENTIFIER = "2.5.29.38";
58
+	const OID_ROLE_SPEC_CERT_IDENTIFIER = "2.5.29.39";
59
+	const OID_CRL_STREAM_IDENTIFIER = "2.5.29.40";
60
+	const OID_BASIC_ATT_CONSTRAINTS = "2.5.29.41";
61
+	const OID_DELEGATED_NAME_CONSTRAINTS = "2.5.29.42";
62
+	const OID_TIME_SPECIFICATION = "2.5.29.43";
63
+	const OID_CRL_SCOPE = "2.5.29.44";
64
+	const OID_STATUS_REFERRALS = "2.5.29.45";
65
+	const OID_FRESHEST_CRL = "2.5.29.46";
66
+	const OID_ORDERED_LIST = "2.5.29.47";
67
+	const OID_ATTRIBUTE_DESCRIPTOR = "2.5.29.48";
68
+	const OID_USER_NOTICE = "2.5.29.49";
69
+	const OID_SOA_IDENTIFIER = "2.5.29.50";
70
+	const OID_BASE_UPDATE_TIME = "2.5.29.51";
71
+	const OID_ACCEPTABLE_CERT_POLICIES = "2.5.29.52";
72
+	const OID_DELTA_INFO = "2.5.29.53";
73
+	const OID_INHIBIT_ANY_POLICY = "2.5.29.54";
74
+	const OID_TARGET_INFORMATION = "2.5.29.55";
75
+	const OID_NO_REV_AVAIL = "2.5.29.56";
76
+	const OID_ACCEPTABLE_PRIVILEGE_POLICIES = "2.5.29.57";
77
+	const OID_TO_BE_REVOKED = "2.5.29.58";
78
+	const OID_REVOKED_GROUPS = "2.5.29.59";
79
+	const OID_EXPIRED_CERTS_ON_CRL = "2.5.29.60";
80
+	const OID_INDIRECT_ISSUER = "2.5.29.61";
81
+	const OID_NO_ASSERTION = "2.5.29.62";
82
+	const OID_AA_ISSUING_DISTRIBUTION_POINT = "2.5.29.63";
83
+	const OID_ISSUED_ON_BEHALF_OF = "2.5.29.64";
84
+	const OID_SINGLE_USE = "2.5.29.65";
85
+	const OID_GROUP_AC = "2.5.29.66";
86
+	const OID_ALLOWED_ATT_ASS = "2.5.29.67";
87
+	const OID_ATTRIBUTE_MAPPINGS = "2.5.29.68";
88
+	const OID_HOLDER_NAME_CONSTRAINTS = "2.5.29.69";
89 89
     
90
-    // OID's from private certificate extensions arc
91
-    const OID_AA_CONTROLS = "1.3.6.1.5.5.7.1.6";
90
+	// OID's from private certificate extensions arc
91
+	const OID_AA_CONTROLS = "1.3.6.1.5.5.7.1.6";
92 92
     
93
-    /**
94
-     * Mapping from extension ID to implementation class name.
95
-     *
96
-     * @internal
97
-     *
98
-     * @var array
99
-     */
100
-    const MAP_OID_TO_CLASS = array(
101
-        /* @formatter:off */
102
-        self::OID_AUTHORITY_KEY_IDENTIFIER => AuthorityKeyIdentifierExtension::class,
103
-        self::OID_SUBJECT_KEY_IDENTIFIER => SubjectKeyIdentifierExtension::class,
104
-        self::OID_KEY_USAGE => KeyUsageExtension::class,
105
-        self::OID_CERTIFICATE_POLICIES => CertificatePoliciesExtension::class,
106
-        self::OID_POLICY_MAPPINGS => PolicyMappingsExtension::class,
107
-        self::OID_SUBJECT_ALT_NAME => SubjectAlternativeNameExtension::class,
108
-        self::OID_ISSUER_ALT_NAME => IssuerAlternativeNameExtension::class,
109
-        self::OID_SUBJECT_DIRECTORY_ATTRIBUTES => SubjectDirectoryAttributesExtension::class,
110
-        self::OID_BASIC_CONSTRAINTS => BasicConstraintsExtension::class,
111
-        self::OID_NAME_CONSTRAINTS => NameConstraintsExtension::class,
112
-        self::OID_POLICY_CONSTRAINTS => PolicyConstraintsExtension::class,
113
-        self::OID_EXT_KEY_USAGE => ExtendedKeyUsageExtension::class,
114
-        self::OID_CRL_DISTRIBUTION_POINTS => CRLDistributionPointsExtension::class,
115
-        self::OID_INHIBIT_ANY_POLICY => InhibitAnyPolicyExtension::class,
116
-        self::OID_FRESHEST_CRL => FreshestCRLExtension::class,
117
-        self::OID_NO_REV_AVAIL => NoRevocationAvailableExtension::class,
118
-        self::OID_TARGET_INFORMATION => TargetInformationExtension::class,
119
-        self::OID_AA_CONTROLS => AAControlsExtension::class
120
-        /* @formatter:on */
121
-    );
93
+	/**
94
+	 * Mapping from extension ID to implementation class name.
95
+	 *
96
+	 * @internal
97
+	 *
98
+	 * @var array
99
+	 */
100
+	const MAP_OID_TO_CLASS = array(
101
+		/* @formatter:off */
102
+		self::OID_AUTHORITY_KEY_IDENTIFIER => AuthorityKeyIdentifierExtension::class,
103
+		self::OID_SUBJECT_KEY_IDENTIFIER => SubjectKeyIdentifierExtension::class,
104
+		self::OID_KEY_USAGE => KeyUsageExtension::class,
105
+		self::OID_CERTIFICATE_POLICIES => CertificatePoliciesExtension::class,
106
+		self::OID_POLICY_MAPPINGS => PolicyMappingsExtension::class,
107
+		self::OID_SUBJECT_ALT_NAME => SubjectAlternativeNameExtension::class,
108
+		self::OID_ISSUER_ALT_NAME => IssuerAlternativeNameExtension::class,
109
+		self::OID_SUBJECT_DIRECTORY_ATTRIBUTES => SubjectDirectoryAttributesExtension::class,
110
+		self::OID_BASIC_CONSTRAINTS => BasicConstraintsExtension::class,
111
+		self::OID_NAME_CONSTRAINTS => NameConstraintsExtension::class,
112
+		self::OID_POLICY_CONSTRAINTS => PolicyConstraintsExtension::class,
113
+		self::OID_EXT_KEY_USAGE => ExtendedKeyUsageExtension::class,
114
+		self::OID_CRL_DISTRIBUTION_POINTS => CRLDistributionPointsExtension::class,
115
+		self::OID_INHIBIT_ANY_POLICY => InhibitAnyPolicyExtension::class,
116
+		self::OID_FRESHEST_CRL => FreshestCRLExtension::class,
117
+		self::OID_NO_REV_AVAIL => NoRevocationAvailableExtension::class,
118
+		self::OID_TARGET_INFORMATION => TargetInformationExtension::class,
119
+		self::OID_AA_CONTROLS => AAControlsExtension::class
120
+		/* @formatter:on */
121
+	);
122 122
     
123
-    /**
124
-     * Extension's OID.
125
-     *
126
-     * @var string $_oid
127
-     */
128
-    protected $_oid;
123
+	/**
124
+	 * Extension's OID.
125
+	 *
126
+	 * @var string $_oid
127
+	 */
128
+	protected $_oid;
129 129
     
130
-    /**
131
-     * Whether extension is critical.
132
-     *
133
-     * @var bool $_critical
134
-     */
135
-    protected $_critical;
130
+	/**
131
+	 * Whether extension is critical.
132
+	 *
133
+	 * @var bool $_critical
134
+	 */
135
+	protected $_critical;
136 136
     
137
-    /**
138
-     * Get ASN.1 structure of the extension value.
139
-     *
140
-     * @return Element
141
-     */
142
-    abstract protected function _valueASN1();
137
+	/**
138
+	 * Get ASN.1 structure of the extension value.
139
+	 *
140
+	 * @return Element
141
+	 */
142
+	abstract protected function _valueASN1();
143 143
     
144
-    /**
145
-     * Parse extension value from DER.
146
-     *
147
-     * @param string $data DER data
148
-     * @param bool $critical Whether extension is critical
149
-     * @throws \BadMethodCallException
150
-     * @return self
151
-     */
152
-    protected static function _fromDER(string $data, bool $critical)
153
-    {
154
-        throw new \BadMethodCallException(
155
-            __FUNCTION__ . " must be implemented in derived class.");
156
-    }
144
+	/**
145
+	 * Parse extension value from DER.
146
+	 *
147
+	 * @param string $data DER data
148
+	 * @param bool $critical Whether extension is critical
149
+	 * @throws \BadMethodCallException
150
+	 * @return self
151
+	 */
152
+	protected static function _fromDER(string $data, bool $critical)
153
+	{
154
+		throw new \BadMethodCallException(
155
+			__FUNCTION__ . " must be implemented in derived class.");
156
+	}
157 157
     
158
-    /**
159
-     * Constructor.
160
-     *
161
-     * @param string $oid Extension OID
162
-     * @param bool $critical Whether extension is critical
163
-     */
164
-    public function __construct(string $oid, bool $critical)
165
-    {
166
-        $this->_oid = $oid;
167
-        $this->_critical = $critical;
168
-    }
158
+	/**
159
+	 * Constructor.
160
+	 *
161
+	 * @param string $oid Extension OID
162
+	 * @param bool $critical Whether extension is critical
163
+	 */
164
+	public function __construct(string $oid, bool $critical)
165
+	{
166
+		$this->_oid = $oid;
167
+		$this->_critical = $critical;
168
+	}
169 169
     
170
-    /**
171
-     * Initialize from ASN.1.
172
-     *
173
-     * @param Sequence $seq
174
-     * @return self
175
-     */
176
-    public static function fromASN1(Sequence $seq): Extension
177
-    {
178
-        $extnID = $seq->at(0)
179
-            ->asObjectIdentifier()
180
-            ->oid();
181
-        $critical = false;
182
-        $idx = 1;
183
-        if ($seq->has($idx, Element::TYPE_BOOLEAN)) {
184
-            $critical = $seq->at($idx++)
185
-                ->asBoolean()
186
-                ->value();
187
-        }
188
-        $data = $seq->at($idx)
189
-            ->asOctetString()
190
-            ->string();
191
-        if (array_key_exists($extnID, self::MAP_OID_TO_CLASS)) {
192
-            $cls = self::MAP_OID_TO_CLASS[$extnID];
193
-            return $cls::_fromDER($data, $critical);
194
-        }
195
-        return new UnknownExtension($extnID, $critical, new DERData($data));
196
-    }
170
+	/**
171
+	 * Initialize from ASN.1.
172
+	 *
173
+	 * @param Sequence $seq
174
+	 * @return self
175
+	 */
176
+	public static function fromASN1(Sequence $seq): Extension
177
+	{
178
+		$extnID = $seq->at(0)
179
+			->asObjectIdentifier()
180
+			->oid();
181
+		$critical = false;
182
+		$idx = 1;
183
+		if ($seq->has($idx, Element::TYPE_BOOLEAN)) {
184
+			$critical = $seq->at($idx++)
185
+				->asBoolean()
186
+				->value();
187
+		}
188
+		$data = $seq->at($idx)
189
+			->asOctetString()
190
+			->string();
191
+		if (array_key_exists($extnID, self::MAP_OID_TO_CLASS)) {
192
+			$cls = self::MAP_OID_TO_CLASS[$extnID];
193
+			return $cls::_fromDER($data, $critical);
194
+		}
195
+		return new UnknownExtension($extnID, $critical, new DERData($data));
196
+	}
197 197
     
198
-    /**
199
-     * Get extension OID.
200
-     *
201
-     * @return string
202
-     */
203
-    public function oid(): string
204
-    {
205
-        return $this->_oid;
206
-    }
198
+	/**
199
+	 * Get extension OID.
200
+	 *
201
+	 * @return string
202
+	 */
203
+	public function oid(): string
204
+	{
205
+		return $this->_oid;
206
+	}
207 207
     
208
-    /**
209
-     * Check whether extension is critical.
210
-     *
211
-     * @return bool
212
-     */
213
-    public function isCritical(): bool
214
-    {
215
-        return $this->_critical;
216
-    }
208
+	/**
209
+	 * Check whether extension is critical.
210
+	 *
211
+	 * @return bool
212
+	 */
213
+	public function isCritical(): bool
214
+	{
215
+		return $this->_critical;
216
+	}
217 217
     
218
-    /**
219
-     * Generate ASN.1 structure.
220
-     *
221
-     * @return Sequence
222
-     */
223
-    public function toASN1(): Sequence
224
-    {
225
-        $elements = array(new ObjectIdentifier($this->_oid));
226
-        if ($this->_critical) {
227
-            $elements[] = new Boolean(true);
228
-        }
229
-        $elements[] = new OctetString($this->_valueASN1()->toDER());
230
-        return new Sequence(...$elements);
231
-    }
218
+	/**
219
+	 * Generate ASN.1 structure.
220
+	 *
221
+	 * @return Sequence
222
+	 */
223
+	public function toASN1(): Sequence
224
+	{
225
+		$elements = array(new ObjectIdentifier($this->_oid));
226
+		if ($this->_critical) {
227
+			$elements[] = new Boolean(true);
228
+		}
229
+		$elements[] = new OctetString($this->_valueASN1()->toDER());
230
+		return new Sequence(...$elements);
231
+	}
232 232
 }
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/SubjectDirectoryAttributesExtension.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -15,55 +15,55 @@
 block discarded – undo
15 15
  * @link https://tools.ietf.org/html/rfc5280#section-4.2.1.8
16 16
  */
17 17
 class SubjectDirectoryAttributesExtension extends Extension implements 
18
-    \Countable,
19
-    \IteratorAggregate
18
+	\Countable,
19
+	\IteratorAggregate
20 20
 {
21
-    use AttributeContainer;
21
+	use AttributeContainer;
22 22
     
23
-    /**
24
-     * Constructor.
25
-     *
26
-     * @param bool $critical
27
-     * @param Attribute ...$attribs One or more Attribute objects
28
-     */
29
-    public function __construct(bool $critical, Attribute ...$attribs)
30
-    {
31
-        parent::__construct(self::OID_SUBJECT_DIRECTORY_ATTRIBUTES, $critical);
32
-        $this->_attributes = $attribs;
33
-    }
23
+	/**
24
+	 * Constructor.
25
+	 *
26
+	 * @param bool $critical
27
+	 * @param Attribute ...$attribs One or more Attribute objects
28
+	 */
29
+	public function __construct(bool $critical, Attribute ...$attribs)
30
+	{
31
+		parent::__construct(self::OID_SUBJECT_DIRECTORY_ATTRIBUTES, $critical);
32
+		$this->_attributes = $attribs;
33
+	}
34 34
     
35
-    /**
36
-     *
37
-     * {@inheritdoc}
38
-     * @return self
39
-     */
40
-    protected static function _fromDER(string $data, bool $critical): self
41
-    {
42
-        $attribs = array_map(
43
-            function (UnspecifiedType $el) {
44
-                return Attribute::fromASN1($el->asSequence());
45
-            }, Sequence::fromDER($data)->elements());
46
-        if (!count($attribs)) {
47
-            throw new \UnexpectedValueException(
48
-                "SubjectDirectoryAttributes must have at least one Attribute.");
49
-        }
50
-        return new self($critical, ...$attribs);
51
-    }
35
+	/**
36
+	 *
37
+	 * {@inheritdoc}
38
+	 * @return self
39
+	 */
40
+	protected static function _fromDER(string $data, bool $critical): self
41
+	{
42
+		$attribs = array_map(
43
+			function (UnspecifiedType $el) {
44
+				return Attribute::fromASN1($el->asSequence());
45
+			}, Sequence::fromDER($data)->elements());
46
+		if (!count($attribs)) {
47
+			throw new \UnexpectedValueException(
48
+				"SubjectDirectoryAttributes must have at least one Attribute.");
49
+		}
50
+		return new self($critical, ...$attribs);
51
+	}
52 52
     
53
-    /**
54
-     *
55
-     * {@inheritdoc}
56
-     * @return Sequence
57
-     */
58
-    protected function _valueASN1(): Sequence
59
-    {
60
-        if (!count($this->_attributes)) {
61
-            throw new \LogicException("No attributes");
62
-        }
63
-        $elements = array_map(
64
-            function (Attribute $attr) {
65
-                return $attr->toASN1();
66
-            }, array_values($this->_attributes));
67
-        return new Sequence(...$elements);
68
-    }
53
+	/**
54
+	 *
55
+	 * {@inheritdoc}
56
+	 * @return Sequence
57
+	 */
58
+	protected function _valueASN1(): Sequence
59
+	{
60
+		if (!count($this->_attributes)) {
61
+			throw new \LogicException("No attributes");
62
+		}
63
+		$elements = array_map(
64
+			function (Attribute $attr) {
65
+				return $attr->toASN1();
66
+			}, array_values($this->_attributes));
67
+		return new Sequence(...$elements);
68
+	}
69 69
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     protected static function _fromDER(string $data, bool $critical): self
41 41
     {
42 42
         $attribs = array_map(
43
-            function (UnspecifiedType $el) {
43
+            function(UnspecifiedType $el) {
44 44
                 return Attribute::fromASN1($el->asSequence());
45 45
             }, Sequence::fromDER($data)->elements());
46 46
         if (!count($attribs)) {
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
             throw new \LogicException("No attributes");
62 62
         }
63 63
         $elements = array_map(
64
-            function (Attribute $attr) {
64
+            function(Attribute $attr) {
65 65
                 return $attr->toASN1();
66 66
             }, array_values($this->_attributes));
67 67
         return new Sequence(...$elements);
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/TargetInformationExtension.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     protected static function _fromDER(string $data, bool $critical): self
78 78
     {
79 79
         $targets = array_map(
80
-            function (UnspecifiedType $el) {
80
+            function(UnspecifiedType $el) {
81 81
                 return Targets::fromASN1($el->asSequence());
82 82
             }, Sequence::fromDER($data)->elements());
83 83
         return new self($critical, ...$targets);
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
     protected function _valueASN1(): Sequence
129 129
     {
130 130
         $elements = array_map(
131
-            function (Targets $targets) {
131
+            function(Targets $targets) {
132 132
                 return $targets->toASN1();
133 133
             }, $this->_targets);
134 134
         return new Sequence(...$elements);
Please login to merge, or discard this patch.
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -19,139 +19,139 @@
 block discarded – undo
19 19
  * @link https://tools.ietf.org/html/rfc5755#section-4.3.2
20 20
  */
21 21
 class TargetInformationExtension extends Extension implements 
22
-    \Countable,
23
-    \IteratorAggregate
22
+	\Countable,
23
+	\IteratorAggregate
24 24
 {
25
-    /**
26
-     * Targets elements.
27
-     *
28
-     * @var Targets[] $_targets
29
-     */
30
-    protected $_targets;
25
+	/**
26
+	 * Targets elements.
27
+	 *
28
+	 * @var Targets[] $_targets
29
+	 */
30
+	protected $_targets;
31 31
     
32
-    /**
33
-     * Targets[] merged to single Targets.
34
-     *
35
-     * @var Targets|null
36
-     */
37
-    private $_merged;
32
+	/**
33
+	 * Targets[] merged to single Targets.
34
+	 *
35
+	 * @var Targets|null
36
+	 */
37
+	private $_merged;
38 38
     
39
-    /**
40
-     * Constructor.
41
-     *
42
-     * @param bool $critical
43
-     * @param Targets ...$targets
44
-     */
45
-    public function __construct(bool $critical, Targets ...$targets)
46
-    {
47
-        parent::__construct(self::OID_TARGET_INFORMATION, $critical);
48
-        $this->_targets = $targets;
49
-    }
39
+	/**
40
+	 * Constructor.
41
+	 *
42
+	 * @param bool $critical
43
+	 * @param Targets ...$targets
44
+	 */
45
+	public function __construct(bool $critical, Targets ...$targets)
46
+	{
47
+		parent::__construct(self::OID_TARGET_INFORMATION, $critical);
48
+		$this->_targets = $targets;
49
+	}
50 50
     
51
-    /**
52
-     * Initialize from one or more Target objects.
53
-     *
54
-     * Extension criticality shall be set to true as specified by RFC 5755.
55
-     *
56
-     * @param Target ...$target
57
-     * @return TargetInformationExtension
58
-     */
59
-    public static function fromTargets(Target ...$target): self
60
-    {
61
-        return new self(true, new Targets(...$target));
62
-    }
51
+	/**
52
+	 * Initialize from one or more Target objects.
53
+	 *
54
+	 * Extension criticality shall be set to true as specified by RFC 5755.
55
+	 *
56
+	 * @param Target ...$target
57
+	 * @return TargetInformationExtension
58
+	 */
59
+	public static function fromTargets(Target ...$target): self
60
+	{
61
+		return new self(true, new Targets(...$target));
62
+	}
63 63
     
64
-    /**
65
-     * Reset internal state on clone.
66
-     */
67
-    public function __clone()
68
-    {
69
-        $this->_merged = null;
70
-    }
64
+	/**
65
+	 * Reset internal state on clone.
66
+	 */
67
+	public function __clone()
68
+	{
69
+		$this->_merged = null;
70
+	}
71 71
     
72
-    /**
73
-     *
74
-     * {@inheritdoc}
75
-     * @return self
76
-     */
77
-    protected static function _fromDER(string $data, bool $critical): self
78
-    {
79
-        $targets = array_map(
80
-            function (UnspecifiedType $el) {
81
-                return Targets::fromASN1($el->asSequence());
82
-            }, Sequence::fromDER($data)->elements());
83
-        return new self($critical, ...$targets);
84
-    }
72
+	/**
73
+	 *
74
+	 * {@inheritdoc}
75
+	 * @return self
76
+	 */
77
+	protected static function _fromDER(string $data, bool $critical): self
78
+	{
79
+		$targets = array_map(
80
+			function (UnspecifiedType $el) {
81
+				return Targets::fromASN1($el->asSequence());
82
+			}, Sequence::fromDER($data)->elements());
83
+		return new self($critical, ...$targets);
84
+	}
85 85
     
86
-    /**
87
-     * Get all targets.
88
-     *
89
-     * @return Targets
90
-     */
91
-    public function targets(): Targets
92
-    {
93
-        if (!isset($this->_merged)) {
94
-            $a = array();
95
-            foreach ($this->_targets as $targets) {
96
-                $a = array_merge($a, $targets->all());
97
-            }
98
-            $this->_merged = new Targets(...$a);
99
-        }
100
-        return $this->_merged;
101
-    }
86
+	/**
87
+	 * Get all targets.
88
+	 *
89
+	 * @return Targets
90
+	 */
91
+	public function targets(): Targets
92
+	{
93
+		if (!isset($this->_merged)) {
94
+			$a = array();
95
+			foreach ($this->_targets as $targets) {
96
+				$a = array_merge($a, $targets->all());
97
+			}
98
+			$this->_merged = new Targets(...$a);
99
+		}
100
+		return $this->_merged;
101
+	}
102 102
     
103
-    /**
104
-     * Get all name targets.
105
-     *
106
-     * @return Target[]
107
-     */
108
-    public function names(): array
109
-    {
110
-        return $this->targets()->nameTargets();
111
-    }
103
+	/**
104
+	 * Get all name targets.
105
+	 *
106
+	 * @return Target[]
107
+	 */
108
+	public function names(): array
109
+	{
110
+		return $this->targets()->nameTargets();
111
+	}
112 112
     
113
-    /**
114
-     * Get all group targets.
115
-     *
116
-     * @return Target[]
117
-     */
118
-    public function groups(): array
119
-    {
120
-        return $this->targets()->groupTargets();
121
-    }
113
+	/**
114
+	 * Get all group targets.
115
+	 *
116
+	 * @return Target[]
117
+	 */
118
+	public function groups(): array
119
+	{
120
+		return $this->targets()->groupTargets();
121
+	}
122 122
     
123
-    /**
124
-     *
125
-     * @see \X509\Certificate\Extension\Extension::_valueASN1()
126
-     * @return Sequence
127
-     */
128
-    protected function _valueASN1(): Sequence
129
-    {
130
-        $elements = array_map(
131
-            function (Targets $targets) {
132
-                return $targets->toASN1();
133
-            }, $this->_targets);
134
-        return new Sequence(...$elements);
135
-    }
123
+	/**
124
+	 *
125
+	 * @see \X509\Certificate\Extension\Extension::_valueASN1()
126
+	 * @return Sequence
127
+	 */
128
+	protected function _valueASN1(): Sequence
129
+	{
130
+		$elements = array_map(
131
+			function (Targets $targets) {
132
+				return $targets->toASN1();
133
+			}, $this->_targets);
134
+		return new Sequence(...$elements);
135
+	}
136 136
     
137
-    /**
138
-     *
139
-     * @see \Countable::count()
140
-     * @return int
141
-     */
142
-    public function count(): int
143
-    {
144
-        return count($this->targets());
145
-    }
137
+	/**
138
+	 *
139
+	 * @see \Countable::count()
140
+	 * @return int
141
+	 */
142
+	public function count(): int
143
+	{
144
+		return count($this->targets());
145
+	}
146 146
     
147
-    /**
148
-     * Get iterator for targets.
149
-     *
150
-     * @see \IteratorAggregate::getIterator()
151
-     * @return \ArrayIterator
152
-     */
153
-    public function getIterator(): \ArrayIterator
154
-    {
155
-        return new \ArrayIterator($this->targets()->all());
156
-    }
147
+	/**
148
+	 * Get iterator for targets.
149
+	 *
150
+	 * @see \IteratorAggregate::getIterator()
151
+	 * @return \ArrayIterator
152
+	 */
153
+	public function getIterator(): \ArrayIterator
154
+	{
155
+		return new \ArrayIterator($this->targets()->all());
156
+	}
157 157
 }
Please login to merge, or discard this patch.
lib/X509/CertificationPath/Policy/PolicyNode.php 1 patch
Indentation   +238 added lines, -238 removed lines patch added patch discarded remove patch
@@ -14,265 +14,265 @@
 block discarded – undo
14 14
  */
15 15
 class PolicyNode implements \IteratorAggregate, \Countable
16 16
 {
17
-    /**
18
-     * Policy OID.
19
-     *
20
-     * @var string
21
-     */
22
-    protected $_validPolicy;
17
+	/**
18
+	 * Policy OID.
19
+	 *
20
+	 * @var string
21
+	 */
22
+	protected $_validPolicy;
23 23
     
24
-    /**
25
-     * List of qualifiers.
26
-     *
27
-     * @var \X509\Certificate\Extension\CertificatePolicy\PolicyQualifierInfo[]
28
-     */
29
-    protected $_qualifiers;
24
+	/**
25
+	 * List of qualifiers.
26
+	 *
27
+	 * @var \X509\Certificate\Extension\CertificatePolicy\PolicyQualifierInfo[]
28
+	 */
29
+	protected $_qualifiers;
30 30
     
31
-    /**
32
-     * List of expected policy OIDs.
33
-     *
34
-     * @var string[]
35
-     */
36
-    protected $_expectedPolicies;
31
+	/**
32
+	 * List of expected policy OIDs.
33
+	 *
34
+	 * @var string[]
35
+	 */
36
+	protected $_expectedPolicies;
37 37
     
38
-    /**
39
-     * List of child nodes.
40
-     *
41
-     * @var PolicyNode[]
42
-     */
43
-    protected $_children;
38
+	/**
39
+	 * List of child nodes.
40
+	 *
41
+	 * @var PolicyNode[]
42
+	 */
43
+	protected $_children;
44 44
     
45
-    /**
46
-     * Reference to the parent node.
47
-     *
48
-     * @var PolicyNode|null
49
-     */
50
-    protected $_parent;
45
+	/**
46
+	 * Reference to the parent node.
47
+	 *
48
+	 * @var PolicyNode|null
49
+	 */
50
+	protected $_parent;
51 51
     
52
-    /**
53
-     * Constructor.
54
-     *
55
-     * @param string $valid_policy Policy OID
56
-     * @param \X509\Certificate\Extension\CertificatePolicy\PolicyQualifierInfo[] $qualifiers
57
-     * @param string[] $expected_policies
58
-     */
59
-    public function __construct(string $valid_policy, array $qualifiers,
60
-        array $expected_policies)
61
-    {
62
-        $this->_validPolicy = $valid_policy;
63
-        $this->_qualifiers = $qualifiers;
64
-        $this->_expectedPolicies = $expected_policies;
65
-        $this->_children = array();
66
-    }
52
+	/**
53
+	 * Constructor.
54
+	 *
55
+	 * @param string $valid_policy Policy OID
56
+	 * @param \X509\Certificate\Extension\CertificatePolicy\PolicyQualifierInfo[] $qualifiers
57
+	 * @param string[] $expected_policies
58
+	 */
59
+	public function __construct(string $valid_policy, array $qualifiers,
60
+		array $expected_policies)
61
+	{
62
+		$this->_validPolicy = $valid_policy;
63
+		$this->_qualifiers = $qualifiers;
64
+		$this->_expectedPolicies = $expected_policies;
65
+		$this->_children = array();
66
+	}
67 67
     
68
-    /**
69
-     * Create initial node for the policy tree.
70
-     *
71
-     * @return self
72
-     */
73
-    public static function anyPolicyNode(): self
74
-    {
75
-        return new self(PolicyInformation::OID_ANY_POLICY, array(),
76
-            array(PolicyInformation::OID_ANY_POLICY));
77
-    }
68
+	/**
69
+	 * Create initial node for the policy tree.
70
+	 *
71
+	 * @return self
72
+	 */
73
+	public static function anyPolicyNode(): self
74
+	{
75
+		return new self(PolicyInformation::OID_ANY_POLICY, array(),
76
+			array(PolicyInformation::OID_ANY_POLICY));
77
+	}
78 78
     
79
-    /**
80
-     * Get the valid policy OID.
81
-     *
82
-     * @return string
83
-     */
84
-    public function validPolicy(): string
85
-    {
86
-        return $this->_validPolicy;
87
-    }
79
+	/**
80
+	 * Get the valid policy OID.
81
+	 *
82
+	 * @return string
83
+	 */
84
+	public function validPolicy(): string
85
+	{
86
+		return $this->_validPolicy;
87
+	}
88 88
     
89
-    /**
90
-     * Check whether node has anyPolicy as a valid policy.
91
-     *
92
-     * @return boolean
93
-     */
94
-    public function isAnyPolicy(): bool
95
-    {
96
-        return PolicyInformation::OID_ANY_POLICY == $this->_validPolicy;
97
-    }
89
+	/**
90
+	 * Check whether node has anyPolicy as a valid policy.
91
+	 *
92
+	 * @return boolean
93
+	 */
94
+	public function isAnyPolicy(): bool
95
+	{
96
+		return PolicyInformation::OID_ANY_POLICY == $this->_validPolicy;
97
+	}
98 98
     
99
-    /**
100
-     * Get the qualifier set.
101
-     *
102
-     * @return \X509\Certificate\Extension\CertificatePolicy\PolicyQualifierInfo[]
103
-     */
104
-    public function qualifiers(): array
105
-    {
106
-        return $this->_qualifiers;
107
-    }
99
+	/**
100
+	 * Get the qualifier set.
101
+	 *
102
+	 * @return \X509\Certificate\Extension\CertificatePolicy\PolicyQualifierInfo[]
103
+	 */
104
+	public function qualifiers(): array
105
+	{
106
+		return $this->_qualifiers;
107
+	}
108 108
     
109
-    /**
110
-     * Check whether node has OID as an expected policy.
111
-     *
112
-     * @param string $oid
113
-     * @return boolean
114
-     */
115
-    public function hasExpectedPolicy(string $oid): bool
116
-    {
117
-        return in_array($oid, $this->_expectedPolicies);
118
-    }
109
+	/**
110
+	 * Check whether node has OID as an expected policy.
111
+	 *
112
+	 * @param string $oid
113
+	 * @return boolean
114
+	 */
115
+	public function hasExpectedPolicy(string $oid): bool
116
+	{
117
+		return in_array($oid, $this->_expectedPolicies);
118
+	}
119 119
     
120
-    /**
121
-     * Get the expected policy set.
122
-     *
123
-     * @return string[]
124
-     */
125
-    public function expectedPolicies(): array
126
-    {
127
-        return $this->_expectedPolicies;
128
-    }
120
+	/**
121
+	 * Get the expected policy set.
122
+	 *
123
+	 * @return string[]
124
+	 */
125
+	public function expectedPolicies(): array
126
+	{
127
+		return $this->_expectedPolicies;
128
+	}
129 129
     
130
-    /**
131
-     * Set expected policies.
132
-     *
133
-     * @param string ...$oids Policy OIDs
134
-     */
135
-    public function setExpectedPolicies(string ...$oids)
136
-    {
137
-        $this->_expectedPolicies = $oids;
138
-    }
130
+	/**
131
+	 * Set expected policies.
132
+	 *
133
+	 * @param string ...$oids Policy OIDs
134
+	 */
135
+	public function setExpectedPolicies(string ...$oids)
136
+	{
137
+		$this->_expectedPolicies = $oids;
138
+	}
139 139
     
140
-    /**
141
-     * Check whether node has a child node with given valid policy OID.
142
-     *
143
-     * @param string $oid
144
-     * @return boolean
145
-     */
146
-    public function hasChildWithValidPolicy(string $oid): bool
147
-    {
148
-        foreach ($this->_children as $node) {
149
-            if ($node->validPolicy() == $oid) {
150
-                return true;
151
-            }
152
-        }
153
-        return false;
154
-    }
140
+	/**
141
+	 * Check whether node has a child node with given valid policy OID.
142
+	 *
143
+	 * @param string $oid
144
+	 * @return boolean
145
+	 */
146
+	public function hasChildWithValidPolicy(string $oid): bool
147
+	{
148
+		foreach ($this->_children as $node) {
149
+			if ($node->validPolicy() == $oid) {
150
+				return true;
151
+			}
152
+		}
153
+		return false;
154
+	}
155 155
     
156
-    /**
157
-     * Add child node.
158
-     *
159
-     * @param PolicyNode $node
160
-     * @return self
161
-     */
162
-    public function addChild(PolicyNode $node): self
163
-    {
164
-        $id = spl_object_hash($node);
165
-        $node->_parent = $this;
166
-        $this->_children[$id] = $node;
167
-        return $this;
168
-    }
156
+	/**
157
+	 * Add child node.
158
+	 *
159
+	 * @param PolicyNode $node
160
+	 * @return self
161
+	 */
162
+	public function addChild(PolicyNode $node): self
163
+	{
164
+		$id = spl_object_hash($node);
165
+		$node->_parent = $this;
166
+		$this->_children[$id] = $node;
167
+		return $this;
168
+	}
169 169
     
170
-    /**
171
-     * Get the child nodes.
172
-     *
173
-     * @return PolicyNode[]
174
-     */
175
-    public function children(): array
176
-    {
177
-        return array_values($this->_children);
178
-    }
170
+	/**
171
+	 * Get the child nodes.
172
+	 *
173
+	 * @return PolicyNode[]
174
+	 */
175
+	public function children(): array
176
+	{
177
+		return array_values($this->_children);
178
+	}
179 179
     
180
-    /**
181
-     * Remove this node from the tree.
182
-     *
183
-     * @return self The removed node
184
-     */
185
-    public function remove(): self
186
-    {
187
-        if ($this->_parent) {
188
-            $id = spl_object_hash($this);
189
-            unset($this->_parent->_children[$id]);
190
-            unset($this->_parent);
191
-        }
192
-        return $this;
193
-    }
180
+	/**
181
+	 * Remove this node from the tree.
182
+	 *
183
+	 * @return self The removed node
184
+	 */
185
+	public function remove(): self
186
+	{
187
+		if ($this->_parent) {
188
+			$id = spl_object_hash($this);
189
+			unset($this->_parent->_children[$id]);
190
+			unset($this->_parent);
191
+		}
192
+		return $this;
193
+	}
194 194
     
195
-    /**
196
-     * Check whether node has a parent.
197
-     *
198
-     * @return bool
199
-     */
200
-    public function hasParent(): bool
201
-    {
202
-        return isset($this->_parent);
203
-    }
195
+	/**
196
+	 * Check whether node has a parent.
197
+	 *
198
+	 * @return bool
199
+	 */
200
+	public function hasParent(): bool
201
+	{
202
+		return isset($this->_parent);
203
+	}
204 204
     
205
-    /**
206
-     * Get the parent node.
207
-     *
208
-     * @return PolicyNode|null
209
-     */
210
-    public function parent()
211
-    {
212
-        return $this->_parent;
213
-    }
205
+	/**
206
+	 * Get the parent node.
207
+	 *
208
+	 * @return PolicyNode|null
209
+	 */
210
+	public function parent()
211
+	{
212
+		return $this->_parent;
213
+	}
214 214
     
215
-    /**
216
-     * Get chain of parent nodes from this node's parent to the root node.
217
-     *
218
-     * @return PolicyNode[]
219
-     */
220
-    public function parents(): array
221
-    {
222
-        if (!$this->_parent) {
223
-            return array();
224
-        }
225
-        $nodes = $this->_parent->parents();
226
-        $nodes[] = $this->_parent;
227
-        return array_reverse($nodes);
228
-    }
215
+	/**
216
+	 * Get chain of parent nodes from this node's parent to the root node.
217
+	 *
218
+	 * @return PolicyNode[]
219
+	 */
220
+	public function parents(): array
221
+	{
222
+		if (!$this->_parent) {
223
+			return array();
224
+		}
225
+		$nodes = $this->_parent->parents();
226
+		$nodes[] = $this->_parent;
227
+		return array_reverse($nodes);
228
+	}
229 229
     
230
-    /**
231
-     * Walk tree from this node, applying a callback for each node.
232
-     *
233
-     * Nodes are traversed depth-first and callback shall be applied post-order.
234
-     *
235
-     * @param callable $fn
236
-     */
237
-    public function walkNodes(callable $fn)
238
-    {
239
-        foreach ($this->_children as $node) {
240
-            $node->walkNodes($fn);
241
-        }
242
-        $fn($this);
243
-    }
230
+	/**
231
+	 * Walk tree from this node, applying a callback for each node.
232
+	 *
233
+	 * Nodes are traversed depth-first and callback shall be applied post-order.
234
+	 *
235
+	 * @param callable $fn
236
+	 */
237
+	public function walkNodes(callable $fn)
238
+	{
239
+		foreach ($this->_children as $node) {
240
+			$node->walkNodes($fn);
241
+		}
242
+		$fn($this);
243
+	}
244 244
     
245
-    /**
246
-     * Get the total number of nodes in a tree.
247
-     *
248
-     * @return int
249
-     */
250
-    public function nodeCount(): int
251
-    {
252
-        $c = 1;
253
-        foreach ($this->_children as $child) {
254
-            $c += $child->nodeCount();
255
-        }
256
-        return $c;
257
-    }
245
+	/**
246
+	 * Get the total number of nodes in a tree.
247
+	 *
248
+	 * @return int
249
+	 */
250
+	public function nodeCount(): int
251
+	{
252
+		$c = 1;
253
+		foreach ($this->_children as $child) {
254
+			$c += $child->nodeCount();
255
+		}
256
+		return $c;
257
+	}
258 258
     
259
-    /**
260
-     * Get the number of child nodes.
261
-     *
262
-     * @see \Countable::count()
263
-     */
264
-    public function count(): int
265
-    {
266
-        return count($this->_children);
267
-    }
259
+	/**
260
+	 * Get the number of child nodes.
261
+	 *
262
+	 * @see \Countable::count()
263
+	 */
264
+	public function count(): int
265
+	{
266
+		return count($this->_children);
267
+	}
268 268
     
269
-    /**
270
-     * Get iterator for the child nodes.
271
-     *
272
-     * @see \IteratorAggregate::getIterator()
273
-     */
274
-    public function getIterator(): \ArrayIterator
275
-    {
276
-        return new \ArrayIterator($this->_children);
277
-    }
269
+	/**
270
+	 * Get iterator for the child nodes.
271
+	 *
272
+	 * @see \IteratorAggregate::getIterator()
273
+	 */
274
+	public function getIterator(): \ArrayIterator
275
+	{
276
+		return new \ArrayIterator($this->_children);
277
+	}
278 278
 }
Please login to merge, or discard this patch.
lib/X509/CertificationPath/CertificationPath.php 1 patch
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -23,171 +23,171 @@
 block discarded – undo
23 23
  */
24 24
 class CertificationPath implements \Countable, \IteratorAggregate
25 25
 {
26
-    /**
27
-     * Certification path.
28
-     *
29
-     * @var Certificate[] $_certificates
30
-     */
31
-    protected $_certificates;
26
+	/**
27
+	 * Certification path.
28
+	 *
29
+	 * @var Certificate[] $_certificates
30
+	 */
31
+	protected $_certificates;
32 32
     
33
-    /**
34
-     * Constructor.
35
-     *
36
-     * @param Certificate ...$certificates Certificates from the trust anchor
37
-     *        to the target end-entity certificate
38
-     */
39
-    public function __construct(Certificate ...$certificates)
40
-    {
41
-        $this->_certificates = $certificates;
42
-    }
33
+	/**
34
+	 * Constructor.
35
+	 *
36
+	 * @param Certificate ...$certificates Certificates from the trust anchor
37
+	 *        to the target end-entity certificate
38
+	 */
39
+	public function __construct(Certificate ...$certificates)
40
+	{
41
+		$this->_certificates = $certificates;
42
+	}
43 43
     
44
-    /**
45
-     * Initialize from a certificate chain.
46
-     *
47
-     * @param CertificateChain $chain
48
-     * @return self
49
-     */
50
-    public static function fromCertificateChain(CertificateChain $chain): self
51
-    {
52
-        return new self(...array_reverse($chain->certificates(), false));
53
-    }
44
+	/**
45
+	 * Initialize from a certificate chain.
46
+	 *
47
+	 * @param CertificateChain $chain
48
+	 * @return self
49
+	 */
50
+	public static function fromCertificateChain(CertificateChain $chain): self
51
+	{
52
+		return new self(...array_reverse($chain->certificates(), false));
53
+	}
54 54
     
55
-    /**
56
-     * Build certification path to given target.
57
-     *
58
-     * @param Certificate $target Target end-entity certificate
59
-     * @param CertificateBundle $trust_anchors List of trust anchors
60
-     * @param CertificateBundle|null $intermediate Optional intermediate
61
-     *        certificates
62
-     * @return self
63
-     */
64
-    public static function toTarget(Certificate $target,
65
-        CertificateBundle $trust_anchors, CertificateBundle $intermediate = null): self
66
-    {
67
-        $builder = new CertificationPathBuilder($trust_anchors);
68
-        return $builder->shortestPathToTarget($target, $intermediate);
69
-    }
55
+	/**
56
+	 * Build certification path to given target.
57
+	 *
58
+	 * @param Certificate $target Target end-entity certificate
59
+	 * @param CertificateBundle $trust_anchors List of trust anchors
60
+	 * @param CertificateBundle|null $intermediate Optional intermediate
61
+	 *        certificates
62
+	 * @return self
63
+	 */
64
+	public static function toTarget(Certificate $target,
65
+		CertificateBundle $trust_anchors, CertificateBundle $intermediate = null): self
66
+	{
67
+		$builder = new CertificationPathBuilder($trust_anchors);
68
+		return $builder->shortestPathToTarget($target, $intermediate);
69
+	}
70 70
     
71
-    /**
72
-     * Build certification path from given trust anchor to target certificate,
73
-     * using intermediate certificates from given bundle.
74
-     *
75
-     * @param Certificate $trust_anchor Trust anchor certificate
76
-     * @param Certificate $target Target end-entity certificate
77
-     * @param CertificateBundle|null $intermediate Optional intermediate
78
-     *        certificates
79
-     * @return self
80
-     */
81
-    public static function fromTrustAnchorToTarget(Certificate $trust_anchor,
82
-        Certificate $target, CertificateBundle $intermediate = null): self
83
-    {
84
-        return self::toTarget($target, new CertificateBundle($trust_anchor),
85
-            $intermediate);
86
-    }
71
+	/**
72
+	 * Build certification path from given trust anchor to target certificate,
73
+	 * using intermediate certificates from given bundle.
74
+	 *
75
+	 * @param Certificate $trust_anchor Trust anchor certificate
76
+	 * @param Certificate $target Target end-entity certificate
77
+	 * @param CertificateBundle|null $intermediate Optional intermediate
78
+	 *        certificates
79
+	 * @return self
80
+	 */
81
+	public static function fromTrustAnchorToTarget(Certificate $trust_anchor,
82
+		Certificate $target, CertificateBundle $intermediate = null): self
83
+	{
84
+		return self::toTarget($target, new CertificateBundle($trust_anchor),
85
+			$intermediate);
86
+	}
87 87
     
88
-    /**
89
-     * Get certificates.
90
-     *
91
-     * @return Certificate[]
92
-     */
93
-    public function certificates(): array
94
-    {
95
-        return $this->_certificates;
96
-    }
88
+	/**
89
+	 * Get certificates.
90
+	 *
91
+	 * @return Certificate[]
92
+	 */
93
+	public function certificates(): array
94
+	{
95
+		return $this->_certificates;
96
+	}
97 97
     
98
-    /**
99
-     * Get the trust anchor certificate from the path.
100
-     *
101
-     * @throws \LogicException If path is empty
102
-     * @return Certificate
103
-     */
104
-    public function trustAnchorCertificate(): Certificate
105
-    {
106
-        if (!count($this->_certificates)) {
107
-            throw new \LogicException("No certificates.");
108
-        }
109
-        return $this->_certificates[0];
110
-    }
98
+	/**
99
+	 * Get the trust anchor certificate from the path.
100
+	 *
101
+	 * @throws \LogicException If path is empty
102
+	 * @return Certificate
103
+	 */
104
+	public function trustAnchorCertificate(): Certificate
105
+	{
106
+		if (!count($this->_certificates)) {
107
+			throw new \LogicException("No certificates.");
108
+		}
109
+		return $this->_certificates[0];
110
+	}
111 111
     
112
-    /**
113
-     * Get the end-entity certificate from the path.
114
-     *
115
-     * @throws \LogicException If path is empty
116
-     * @return Certificate
117
-     */
118
-    public function endEntityCertificate(): Certificate
119
-    {
120
-        if (!count($this->_certificates)) {
121
-            throw new \LogicException("No certificates.");
122
-        }
123
-        return $this->_certificates[count($this->_certificates) - 1];
124
-    }
112
+	/**
113
+	 * Get the end-entity certificate from the path.
114
+	 *
115
+	 * @throws \LogicException If path is empty
116
+	 * @return Certificate
117
+	 */
118
+	public function endEntityCertificate(): Certificate
119
+	{
120
+		if (!count($this->_certificates)) {
121
+			throw new \LogicException("No certificates.");
122
+		}
123
+		return $this->_certificates[count($this->_certificates) - 1];
124
+	}
125 125
     
126
-    /**
127
-     * Get certification path as a certificate chain.
128
-     *
129
-     * @return CertificateChain
130
-     */
131
-    public function certificateChain(): CertificateChain
132
-    {
133
-        return new CertificateChain(
134
-            ...array_reverse($this->_certificates, false));
135
-    }
126
+	/**
127
+	 * Get certification path as a certificate chain.
128
+	 *
129
+	 * @return CertificateChain
130
+	 */
131
+	public function certificateChain(): CertificateChain
132
+	{
133
+		return new CertificateChain(
134
+			...array_reverse($this->_certificates, false));
135
+	}
136 136
     
137
-    /**
138
-     * Check whether certification path starts with one ore more given
139
-     * certificates in parameter order.
140
-     *
141
-     * @param Certificate ...$certs Certificates
142
-     * @return true
143
-     */
144
-    public function startsWith(Certificate ...$certs): bool
145
-    {
146
-        $n = count($certs);
147
-        if ($n > count($this->_certificates)) {
148
-            return false;
149
-        }
150
-        for ($i = 0; $i < $n; ++$i) {
151
-            if (!$certs[$i]->equals($this->_certificates[$i])) {
152
-                return false;
153
-            }
154
-        }
155
-        return true;
156
-    }
137
+	/**
138
+	 * Check whether certification path starts with one ore more given
139
+	 * certificates in parameter order.
140
+	 *
141
+	 * @param Certificate ...$certs Certificates
142
+	 * @return true
143
+	 */
144
+	public function startsWith(Certificate ...$certs): bool
145
+	{
146
+		$n = count($certs);
147
+		if ($n > count($this->_certificates)) {
148
+			return false;
149
+		}
150
+		for ($i = 0; $i < $n; ++$i) {
151
+			if (!$certs[$i]->equals($this->_certificates[$i])) {
152
+				return false;
153
+			}
154
+		}
155
+		return true;
156
+	}
157 157
     
158
-    /**
159
-     * Validate certification path.
160
-     *
161
-     * @param PathValidationConfig $config
162
-     * @param Crypto|null $crypto Crypto engine, use default if not set
163
-     * @throws Exception\PathValidationException
164
-     * @return PathValidation\PathValidationResult
165
-     */
166
-    public function validate(PathValidationConfig $config, Crypto $crypto = null): PathValidation\PathValidationResult
167
-    {
168
-        $crypto = $crypto ?: Crypto::getDefault();
169
-        $validator = new PathValidator($crypto, $config, ...$this->_certificates);
170
-        return $validator->validate();
171
-    }
158
+	/**
159
+	 * Validate certification path.
160
+	 *
161
+	 * @param PathValidationConfig $config
162
+	 * @param Crypto|null $crypto Crypto engine, use default if not set
163
+	 * @throws Exception\PathValidationException
164
+	 * @return PathValidation\PathValidationResult
165
+	 */
166
+	public function validate(PathValidationConfig $config, Crypto $crypto = null): PathValidation\PathValidationResult
167
+	{
168
+		$crypto = $crypto ?: Crypto::getDefault();
169
+		$validator = new PathValidator($crypto, $config, ...$this->_certificates);
170
+		return $validator->validate();
171
+	}
172 172
     
173
-    /**
174
-     *
175
-     * @see \Countable::count()
176
-     * @return int
177
-     */
178
-    public function count(): int
179
-    {
180
-        return count($this->_certificates);
181
-    }
173
+	/**
174
+	 *
175
+	 * @see \Countable::count()
176
+	 * @return int
177
+	 */
178
+	public function count(): int
179
+	{
180
+		return count($this->_certificates);
181
+	}
182 182
     
183
-    /**
184
-     * Get iterator for certificates.
185
-     *
186
-     * @see \IteratorAggregate::getIterator()
187
-     * @return \ArrayIterator
188
-     */
189
-    public function getIterator(): \ArrayIterator
190
-    {
191
-        return new \ArrayIterator($this->_certificates);
192
-    }
183
+	/**
184
+	 * Get iterator for certificates.
185
+	 *
186
+	 * @see \IteratorAggregate::getIterator()
187
+	 * @return \ArrayIterator
188
+	 */
189
+	public function getIterator(): \ArrayIterator
190
+	{
191
+		return new \ArrayIterator($this->_certificates);
192
+	}
193 193
 }
Please login to merge, or discard this patch.
lib/X509/CertificationPath/PathValidation/PathValidationConfig.php 1 patch
Indentation   +245 added lines, -245 removed lines patch added patch discarded remove patch
@@ -14,274 +14,274 @@
 block discarded – undo
14 14
  */
15 15
 class PathValidationConfig
16 16
 {
17
-    /**
18
-     * Maximum allowed certification path length.
19
-     *
20
-     * @var int $_maxLength
21
-     */
22
-    protected $_maxLength;
17
+	/**
18
+	 * Maximum allowed certification path length.
19
+	 *
20
+	 * @var int $_maxLength
21
+	 */
22
+	protected $_maxLength;
23 23
     
24
-    /**
25
-     * Reference time.
26
-     *
27
-     * @var \DateTimeImmutable $_dateTime
28
-     */
29
-    protected $_dateTime;
24
+	/**
25
+	 * Reference time.
26
+	 *
27
+	 * @var \DateTimeImmutable $_dateTime
28
+	 */
29
+	protected $_dateTime;
30 30
     
31
-    /**
32
-     * List of acceptable policy identifiers.
33
-     *
34
-     * @var string[] $_policySet
35
-     */
36
-    protected $_policySet;
31
+	/**
32
+	 * List of acceptable policy identifiers.
33
+	 *
34
+	 * @var string[] $_policySet
35
+	 */
36
+	protected $_policySet;
37 37
     
38
-    /**
39
-     * Trust anchor certificate.
40
-     *
41
-     * If not set, path validation uses the first certificate of the path.
42
-     *
43
-     * @var Certificate|null $_trustAnchor
44
-     */
45
-    protected $_trustAnchor;
38
+	/**
39
+	 * Trust anchor certificate.
40
+	 *
41
+	 * If not set, path validation uses the first certificate of the path.
42
+	 *
43
+	 * @var Certificate|null $_trustAnchor
44
+	 */
45
+	protected $_trustAnchor;
46 46
     
47
-    /**
48
-     * Whether policy mapping in inhibited.
49
-     *
50
-     * Setting this to true disallows policy mapping.
51
-     *
52
-     * @var bool $_policyMappingInhibit
53
-     */
54
-    protected $_policyMappingInhibit;
47
+	/**
48
+	 * Whether policy mapping in inhibited.
49
+	 *
50
+	 * Setting this to true disallows policy mapping.
51
+	 *
52
+	 * @var bool $_policyMappingInhibit
53
+	 */
54
+	protected $_policyMappingInhibit;
55 55
     
56
-    /**
57
-     * Whether the path must be valid for at least one policy in the
58
-     * initial policy set.
59
-     *
60
-     * @var bool $_explicitPolicy
61
-     */
62
-    protected $_explicitPolicy;
56
+	/**
57
+	 * Whether the path must be valid for at least one policy in the
58
+	 * initial policy set.
59
+	 *
60
+	 * @var bool $_explicitPolicy
61
+	 */
62
+	protected $_explicitPolicy;
63 63
     
64
-    /**
65
-     * Whether anyPolicy OID processing should be inhibited.
66
-     *
67
-     * Setting this to true disallows the usage of anyPolicy.
68
-     *
69
-     * @var bool $_anyPolicyInhibit
70
-     */
71
-    protected $_anyPolicyInhibit;
64
+	/**
65
+	 * Whether anyPolicy OID processing should be inhibited.
66
+	 *
67
+	 * Setting this to true disallows the usage of anyPolicy.
68
+	 *
69
+	 * @var bool $_anyPolicyInhibit
70
+	 */
71
+	protected $_anyPolicyInhibit;
72 72
     
73
-    /**
74
-     *
75
-     * @todo Implement
76
-     * @var mixed $_permittedSubtrees
77
-     */
78
-    protected $_permittedSubtrees;
73
+	/**
74
+	 *
75
+	 * @todo Implement
76
+	 * @var mixed $_permittedSubtrees
77
+	 */
78
+	protected $_permittedSubtrees;
79 79
     
80
-    /**
81
-     *
82
-     * @todo Implement
83
-     * @var mixed $_excludedSubtrees
84
-     */
85
-    protected $_excludedSubtrees;
80
+	/**
81
+	 *
82
+	 * @todo Implement
83
+	 * @var mixed $_excludedSubtrees
84
+	 */
85
+	protected $_excludedSubtrees;
86 86
     
87
-    /**
88
-     * Constructor.
89
-     *
90
-     * @param \DateTimeImmutable $dt Reference date and time
91
-     * @param int $max_length Maximum certification path length
92
-     */
93
-    public function __construct(\DateTimeImmutable $dt, int $max_length)
94
-    {
95
-        $this->_dateTime = $dt;
96
-        $this->_maxLength = (int) $max_length;
97
-        $this->_policySet = array((string) PolicyInformation::OID_ANY_POLICY);
98
-        $this->_policyMappingInhibit = false;
99
-        $this->_explicitPolicy = false;
100
-        $this->_anyPolicyInhibit = false;
101
-    }
87
+	/**
88
+	 * Constructor.
89
+	 *
90
+	 * @param \DateTimeImmutable $dt Reference date and time
91
+	 * @param int $max_length Maximum certification path length
92
+	 */
93
+	public function __construct(\DateTimeImmutable $dt, int $max_length)
94
+	{
95
+		$this->_dateTime = $dt;
96
+		$this->_maxLength = (int) $max_length;
97
+		$this->_policySet = array((string) PolicyInformation::OID_ANY_POLICY);
98
+		$this->_policyMappingInhibit = false;
99
+		$this->_explicitPolicy = false;
100
+		$this->_anyPolicyInhibit = false;
101
+	}
102 102
     
103
-    /**
104
-     * Get default configuration.
105
-     *
106
-     * @return self
107
-     */
108
-    public static function defaultConfig(): self
109
-    {
110
-        return new self(new \DateTimeImmutable(), 3);
111
-    }
103
+	/**
104
+	 * Get default configuration.
105
+	 *
106
+	 * @return self
107
+	 */
108
+	public static function defaultConfig(): self
109
+	{
110
+		return new self(new \DateTimeImmutable(), 3);
111
+	}
112 112
     
113
-    /**
114
-     * Get self with maximum path length.
115
-     *
116
-     * @param int $length
117
-     * @return self
118
-     */
119
-    public function withMaxLength(int $length): self
120
-    {
121
-        $obj = clone $this;
122
-        $obj->_maxLength = $length;
123
-        return $obj;
124
-    }
113
+	/**
114
+	 * Get self with maximum path length.
115
+	 *
116
+	 * @param int $length
117
+	 * @return self
118
+	 */
119
+	public function withMaxLength(int $length): self
120
+	{
121
+		$obj = clone $this;
122
+		$obj->_maxLength = $length;
123
+		return $obj;
124
+	}
125 125
     
126
-    /**
127
-     * Get self with reference date and time.
128
-     *
129
-     * @param \DateTimeImmutable $dt
130
-     * @return self
131
-     */
132
-    public function withDateTime(\DateTimeImmutable $dt): self
133
-    {
134
-        $obj = clone $this;
135
-        $obj->_dateTime = $dt;
136
-        return $obj;
137
-    }
126
+	/**
127
+	 * Get self with reference date and time.
128
+	 *
129
+	 * @param \DateTimeImmutable $dt
130
+	 * @return self
131
+	 */
132
+	public function withDateTime(\DateTimeImmutable $dt): self
133
+	{
134
+		$obj = clone $this;
135
+		$obj->_dateTime = $dt;
136
+		return $obj;
137
+	}
138 138
     
139
-    /**
140
-     * Get self with trust anchor certificate.
141
-     *
142
-     * @param Certificate $ca
143
-     * @return self
144
-     */
145
-    public function withTrustAnchor(Certificate $ca): self
146
-    {
147
-        $obj = clone $this;
148
-        $obj->_trustAnchor = $ca;
149
-        return $obj;
150
-    }
139
+	/**
140
+	 * Get self with trust anchor certificate.
141
+	 *
142
+	 * @param Certificate $ca
143
+	 * @return self
144
+	 */
145
+	public function withTrustAnchor(Certificate $ca): self
146
+	{
147
+		$obj = clone $this;
148
+		$obj->_trustAnchor = $ca;
149
+		return $obj;
150
+	}
151 151
     
152
-    /**
153
-     * Get self with initial-policy-mapping-inhibit set.
154
-     *
155
-     * @param bool $flag
156
-     * @return self
157
-     */
158
-    public function withPolicyMappingInhibit(bool $flag): self
159
-    {
160
-        $obj = clone $this;
161
-        $obj->_policyMappingInhibit = $flag;
162
-        return $obj;
163
-    }
152
+	/**
153
+	 * Get self with initial-policy-mapping-inhibit set.
154
+	 *
155
+	 * @param bool $flag
156
+	 * @return self
157
+	 */
158
+	public function withPolicyMappingInhibit(bool $flag): self
159
+	{
160
+		$obj = clone $this;
161
+		$obj->_policyMappingInhibit = $flag;
162
+		return $obj;
163
+	}
164 164
     
165
-    /**
166
-     * Get self with initial-explicit-policy set.
167
-     *
168
-     * @param bool $flag
169
-     * @return self
170
-     */
171
-    public function withExplicitPolicy(bool $flag): self
172
-    {
173
-        $obj = clone $this;
174
-        $obj->_explicitPolicy = $flag;
175
-        return $obj;
176
-    }
165
+	/**
166
+	 * Get self with initial-explicit-policy set.
167
+	 *
168
+	 * @param bool $flag
169
+	 * @return self
170
+	 */
171
+	public function withExplicitPolicy(bool $flag): self
172
+	{
173
+		$obj = clone $this;
174
+		$obj->_explicitPolicy = $flag;
175
+		return $obj;
176
+	}
177 177
     
178
-    /**
179
-     * Get self with initial-any-policy-inhibit set.
180
-     *
181
-     * @param bool $flag
182
-     * @return self
183
-     */
184
-    public function withAnyPolicyInhibit(bool $flag): self
185
-    {
186
-        $obj = clone $this;
187
-        $obj->_anyPolicyInhibit = $flag;
188
-        return $obj;
189
-    }
178
+	/**
179
+	 * Get self with initial-any-policy-inhibit set.
180
+	 *
181
+	 * @param bool $flag
182
+	 * @return self
183
+	 */
184
+	public function withAnyPolicyInhibit(bool $flag): self
185
+	{
186
+		$obj = clone $this;
187
+		$obj->_anyPolicyInhibit = $flag;
188
+		return $obj;
189
+	}
190 190
     
191
-    /**
192
-     * Get self with user-initial-policy-set set to policy OIDs.
193
-     *
194
-     * @param string ...$policies List of policy OIDs
195
-     * @return self
196
-     */
197
-    public function withPolicySet(string ...$policies): self
198
-    {
199
-        $obj = clone $this;
200
-        $obj->_policySet = $policies;
201
-        return $obj;
202
-    }
191
+	/**
192
+	 * Get self with user-initial-policy-set set to policy OIDs.
193
+	 *
194
+	 * @param string ...$policies List of policy OIDs
195
+	 * @return self
196
+	 */
197
+	public function withPolicySet(string ...$policies): self
198
+	{
199
+		$obj = clone $this;
200
+		$obj->_policySet = $policies;
201
+		return $obj;
202
+	}
203 203
     
204
-    /**
205
-     * Get maximum certification path length.
206
-     *
207
-     * @return int
208
-     */
209
-    public function maxLength(): int
210
-    {
211
-        return $this->_maxLength;
212
-    }
204
+	/**
205
+	 * Get maximum certification path length.
206
+	 *
207
+	 * @return int
208
+	 */
209
+	public function maxLength(): int
210
+	{
211
+		return $this->_maxLength;
212
+	}
213 213
     
214
-    /**
215
-     * Get reference date and time.
216
-     *
217
-     * @return \DateTimeImmutable
218
-     */
219
-    public function dateTime(): \DateTimeImmutable
220
-    {
221
-        return $this->_dateTime;
222
-    }
214
+	/**
215
+	 * Get reference date and time.
216
+	 *
217
+	 * @return \DateTimeImmutable
218
+	 */
219
+	public function dateTime(): \DateTimeImmutable
220
+	{
221
+		return $this->_dateTime;
222
+	}
223 223
     
224
-    /**
225
-     * Get user-initial-policy-set.
226
-     *
227
-     * @return string[] Array of OID's
228
-     */
229
-    public function policySet(): array
230
-    {
231
-        return $this->_policySet;
232
-    }
224
+	/**
225
+	 * Get user-initial-policy-set.
226
+	 *
227
+	 * @return string[] Array of OID's
228
+	 */
229
+	public function policySet(): array
230
+	{
231
+		return $this->_policySet;
232
+	}
233 233
     
234
-    /**
235
-     * Check whether trust anchor certificate is set.
236
-     *
237
-     * @return bool
238
-     */
239
-    public function hasTrustAnchor(): bool
240
-    {
241
-        return isset($this->_trustAnchor);
242
-    }
234
+	/**
235
+	 * Check whether trust anchor certificate is set.
236
+	 *
237
+	 * @return bool
238
+	 */
239
+	public function hasTrustAnchor(): bool
240
+	{
241
+		return isset($this->_trustAnchor);
242
+	}
243 243
     
244
-    /**
245
-     * Get trust anchor certificate.
246
-     *
247
-     * @throws \LogicException
248
-     * @return Certificate
249
-     */
250
-    public function trustAnchor(): Certificate
251
-    {
252
-        if (!$this->hasTrustAnchor()) {
253
-            throw new \LogicException("No trust anchor.");
254
-        }
255
-        return $this->_trustAnchor;
256
-    }
244
+	/**
245
+	 * Get trust anchor certificate.
246
+	 *
247
+	 * @throws \LogicException
248
+	 * @return Certificate
249
+	 */
250
+	public function trustAnchor(): Certificate
251
+	{
252
+		if (!$this->hasTrustAnchor()) {
253
+			throw new \LogicException("No trust anchor.");
254
+		}
255
+		return $this->_trustAnchor;
256
+	}
257 257
     
258
-    /**
259
-     * Get initial-policy-mapping-inhibit.
260
-     *
261
-     * @return bool
262
-     */
263
-    public function policyMappingInhibit(): bool
264
-    {
265
-        return $this->_policyMappingInhibit;
266
-    }
258
+	/**
259
+	 * Get initial-policy-mapping-inhibit.
260
+	 *
261
+	 * @return bool
262
+	 */
263
+	public function policyMappingInhibit(): bool
264
+	{
265
+		return $this->_policyMappingInhibit;
266
+	}
267 267
     
268
-    /**
269
-     * Get initial-explicit-policy.
270
-     *
271
-     * @return bool
272
-     */
273
-    public function explicitPolicy(): bool
274
-    {
275
-        return $this->_explicitPolicy;
276
-    }
268
+	/**
269
+	 * Get initial-explicit-policy.
270
+	 *
271
+	 * @return bool
272
+	 */
273
+	public function explicitPolicy(): bool
274
+	{
275
+		return $this->_explicitPolicy;
276
+	}
277 277
     
278
-    /**
279
-     * Get initial-any-policy-inhibit.
280
-     *
281
-     * @return bool
282
-     */
283
-    public function anyPolicyInhibit(): bool
284
-    {
285
-        return $this->_anyPolicyInhibit;
286
-    }
278
+	/**
279
+	 * Get initial-any-policy-inhibit.
280
+	 *
281
+	 * @return bool
282
+	 */
283
+	public function anyPolicyInhibit(): bool
284
+	{
285
+		return $this->_anyPolicyInhibit;
286
+	}
287 287
 }
Please login to merge, or discard this patch.