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 ( 584877...f7ba31 )
by Joni
05:42
created
lib/X509/AttributeCertificate/Attribute/GroupAttributeValue.php 1 patch
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 GroupAttributeValue extends IetfAttrSyntax
13 13
 {
14
-    const OID = "1.3.6.1.5.5.7.10.4";
14
+	const OID = "1.3.6.1.5.5.7.10.4";
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.
lib/X509/AttributeCertificate/Attribute/ChargingIdentityAttributeValue.php 1 patch
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.
lib/X509/Certificate/Extension/FreshestCRLExtension.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -13,16 +13,16 @@
 block discarded – undo
13 13
  */
14 14
 class FreshestCRLExtension extends CRLDistributionPointsExtension
15 15
 {
16
-    /**
17
-     * Constructor.
18
-     *
19
-     * @param bool $critical
20
-     * @param DistributionPoint ...$distribution_points
21
-     */
22
-    public function __construct(bool $critical,
23
-        DistributionPoint ...$distribution_points)
24
-    {
25
-        Extension::__construct(self::OID_FRESHEST_CRL, $critical);
26
-        $this->_distributionPoints = $distribution_points;
27
-    }
16
+	/**
17
+	 * Constructor.
18
+	 *
19
+	 * @param bool $critical
20
+	 * @param DistributionPoint ...$distribution_points
21
+	 */
22
+	public function __construct(bool $critical,
23
+		DistributionPoint ...$distribution_points)
24
+	{
25
+		Extension::__construct(self::OID_FRESHEST_CRL, $critical);
26
+		$this->_distributionPoints = $distribution_points;
27
+	}
28 28
 }
Please login to merge, or discard this patch.
lib/X509/CertificationPath/PathValidation/PathValidationResult.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -16,85 +16,85 @@
 block discarded – undo
16 16
  */
17 17
 class PathValidationResult
18 18
 {
19
-    /**
20
-     * Certificates in a certification path.
21
-     *
22
-     * @var \X509\Certificate\Certificate[] $_certificates
23
-     */
24
-    protected $_certificates;
19
+	/**
20
+	 * Certificates in a certification path.
21
+	 *
22
+	 * @var \X509\Certificate\Certificate[] $_certificates
23
+	 */
24
+	protected $_certificates;
25 25
     
26
-    /**
27
-     * Valid policy tree.
28
-     *
29
-     * @var \X509\CertificationPath\Policy\PolicyTree|null $_policyTree
30
-     */
31
-    protected $_policyTree;
26
+	/**
27
+	 * Valid policy tree.
28
+	 *
29
+	 * @var \X509\CertificationPath\Policy\PolicyTree|null $_policyTree
30
+	 */
31
+	protected $_policyTree;
32 32
     
33
-    /**
34
-     * End-entity certificate's public key.
35
-     *
36
-     * @var PublicKeyInfo
37
-     */
38
-    protected $_publicKeyInfo;
33
+	/**
34
+	 * End-entity certificate's public key.
35
+	 *
36
+	 * @var PublicKeyInfo
37
+	 */
38
+	protected $_publicKeyInfo;
39 39
     
40
-    /**
41
-     * Public key algorithm.
42
-     *
43
-     * @var AlgorithmIdentifierType
44
-     */
45
-    protected $_publicKeyAlgo;
40
+	/**
41
+	 * Public key algorithm.
42
+	 *
43
+	 * @var AlgorithmIdentifierType
44
+	 */
45
+	protected $_publicKeyAlgo;
46 46
     
47
-    /**
48
-     * Public key parameters.
49
-     *
50
-     * @var Element|null $_publicKeyParameters
51
-     */
52
-    protected $_publicKeyParameters;
47
+	/**
48
+	 * Public key parameters.
49
+	 *
50
+	 * @var Element|null $_publicKeyParameters
51
+	 */
52
+	protected $_publicKeyParameters;
53 53
     
54
-    /**
55
-     * Constructor.
56
-     *
57
-     * @param \X509\Certificate\Certificate[] $certificates Certificates in a
58
-     *        certification path
59
-     * @param \X509\CertificationPath\Policy\PolicyTree|null $policy_tree Valid
60
-     *        policy tree
61
-     * @param PublicKeyInfo $pubkey_info Public key of the end-entity
62
-     *        certificate
63
-     * @param AlgorithmIdentifierType $algo Public key algorithm of the
64
-     *        end-entity certificate
65
-     * @param Element|null $params Algorithm parameters
66
-     */
67
-    public function __construct(array $certificates, $policy_tree,
68
-        PublicKeyInfo $pubkey_info, AlgorithmIdentifierType $algo,
69
-        Element $params = null)
70
-    {
71
-        $this->_certificates = array_values($certificates);
72
-        $this->_policyTree = $policy_tree;
73
-        $this->_publicKeyInfo = $pubkey_info;
74
-        $this->_publicKeyAlgo = $algo;
75
-        $this->_publicKeyParameters = $params;
76
-    }
54
+	/**
55
+	 * Constructor.
56
+	 *
57
+	 * @param \X509\Certificate\Certificate[] $certificates Certificates in a
58
+	 *        certification path
59
+	 * @param \X509\CertificationPath\Policy\PolicyTree|null $policy_tree Valid
60
+	 *        policy tree
61
+	 * @param PublicKeyInfo $pubkey_info Public key of the end-entity
62
+	 *        certificate
63
+	 * @param AlgorithmIdentifierType $algo Public key algorithm of the
64
+	 *        end-entity certificate
65
+	 * @param Element|null $params Algorithm parameters
66
+	 */
67
+	public function __construct(array $certificates, $policy_tree,
68
+		PublicKeyInfo $pubkey_info, AlgorithmIdentifierType $algo,
69
+		Element $params = null)
70
+	{
71
+		$this->_certificates = array_values($certificates);
72
+		$this->_policyTree = $policy_tree;
73
+		$this->_publicKeyInfo = $pubkey_info;
74
+		$this->_publicKeyAlgo = $algo;
75
+		$this->_publicKeyParameters = $params;
76
+	}
77 77
     
78
-    /**
79
-     * Get end-entity certificate.
80
-     *
81
-     * @return \X509\Certificate\Certificate
82
-     */
83
-    public function certificate(): Certificate
84
-    {
85
-        return $this->_certificates[count($this->_certificates) - 1];
86
-    }
78
+	/**
79
+	 * Get end-entity certificate.
80
+	 *
81
+	 * @return \X509\Certificate\Certificate
82
+	 */
83
+	public function certificate(): Certificate
84
+	{
85
+		return $this->_certificates[count($this->_certificates) - 1];
86
+	}
87 87
     
88
-    /**
89
-     * Get certificate policies of the end-entity certificate.
90
-     *
91
-     * @return \X509\Certificate\Extension\CertificatePolicy\PolicyInformation[]
92
-     */
93
-    public function policies(): array
94
-    {
95
-        if (!$this->_policyTree) {
96
-            return array();
97
-        }
98
-        return $this->_policyTree->policiesAtDepth(count($this->_certificates));
99
-    }
88
+	/**
89
+	 * Get certificate policies of the end-entity certificate.
90
+	 *
91
+	 * @return \X509\Certificate\Extension\CertificatePolicy\PolicyInformation[]
92
+	 */
93
+	public function policies(): array
94
+	{
95
+		if (!$this->_policyTree) {
96
+			return array();
97
+		}
98
+		return $this->_policyTree->policiesAtDepth(count($this->_certificates));
99
+	}
100 100
 }
Please login to merge, or discard this patch.
lib/X509/CertificationPath/PathBuilding/CertificationPathBuilder.php 1 patch
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -16,137 +16,137 @@
 block discarded – undo
16 16
  */
17 17
 class CertificationPathBuilder
18 18
 {
19
-    /**
20
-     * Trust anchors.
21
-     *
22
-     * @var CertificateBundle
23
-     */
24
-    protected $_trustList;
19
+	/**
20
+	 * Trust anchors.
21
+	 *
22
+	 * @var CertificateBundle
23
+	 */
24
+	protected $_trustList;
25 25
     
26
-    /**
27
-     * Constructor.
28
-     *
29
-     * @param CertificateBundle $trust_list List of trust anchors
30
-     */
31
-    public function __construct(CertificateBundle $trust_list)
32
-    {
33
-        $this->_trustList = $trust_list;
34
-    }
26
+	/**
27
+	 * Constructor.
28
+	 *
29
+	 * @param CertificateBundle $trust_list List of trust anchors
30
+	 */
31
+	public function __construct(CertificateBundle $trust_list)
32
+	{
33
+		$this->_trustList = $trust_list;
34
+	}
35 35
     
36
-    /**
37
-     * Get all certification paths to given target certificate from
38
-     * any trust anchor.
39
-     *
40
-     * @param Certificate $target Target certificate
41
-     * @param CertificateBundle|null $intermediate Optional intermediate
42
-     *        certificates
43
-     * @return CertificationPath[]
44
-     */
45
-    public function allPathsToTarget(Certificate $target,
46
-        CertificateBundle $intermediate = null): array
47
-    {
48
-        $paths = $this->_resolvePathsToTarget($target, $intermediate);
49
-        // map paths to CertificationPath objects
50
-        return array_map(
51
-            function ($certs) {
52
-                return new CertificationPath(...$certs);
53
-            }, $paths);
54
-    }
36
+	/**
37
+	 * Get all certification paths to given target certificate from
38
+	 * any trust anchor.
39
+	 *
40
+	 * @param Certificate $target Target certificate
41
+	 * @param CertificateBundle|null $intermediate Optional intermediate
42
+	 *        certificates
43
+	 * @return CertificationPath[]
44
+	 */
45
+	public function allPathsToTarget(Certificate $target,
46
+		CertificateBundle $intermediate = null): array
47
+	{
48
+		$paths = $this->_resolvePathsToTarget($target, $intermediate);
49
+		// map paths to CertificationPath objects
50
+		return array_map(
51
+			function ($certs) {
52
+				return new CertificationPath(...$certs);
53
+			}, $paths);
54
+	}
55 55
     
56
-    /**
57
-     * Resolve all possible certification paths from any trust anchor to
58
-     * the target certificate, using optional intermediate certificates.
59
-     *
60
-     * Helper method for allPathsToTarget to be called recursively.
61
-     *
62
-     * @todo Implement loop detection
63
-     * @param Certificate $target
64
-     * @param CertificateBundle $intermediate
65
-     * @return array[] Array of arrays containing path certificates
66
-     */
67
-    private function _resolvePathsToTarget(Certificate $target,
68
-        CertificateBundle $intermediate = null): array
69
-    {
70
-        // array of possible paths
71
-        $paths = array();
72
-        // signed by certificate in the trust list
73
-        foreach ($this->_findIssuers($target, $this->_trustList) as $issuer) {
74
-            // if target is self-signed, path consists of only
75
-            // the target certificate
76
-            if ($target->equals($issuer)) {
77
-                $paths[] = array($target);
78
-            } else {
79
-                $paths[] = array($issuer, $target);
80
-            }
81
-        }
82
-        if (isset($intermediate)) {
83
-            // signed by intermediate certificate
84
-            foreach ($this->_findIssuers($target, $intermediate) as $issuer) {
85
-                // intermediate certificate must not be self-signed
86
-                if ($issuer->isSelfIssued()) {
87
-                    continue;
88
-                }
89
-                // resolve paths to issuer
90
-                $subpaths = $this->_resolvePathsToTarget($issuer, $intermediate);
91
-                foreach ($subpaths as $path) {
92
-                    $paths[] = array_merge($path, array($target));
93
-                }
94
-            }
95
-        }
96
-        return $paths;
97
-    }
56
+	/**
57
+	 * Resolve all possible certification paths from any trust anchor to
58
+	 * the target certificate, using optional intermediate certificates.
59
+	 *
60
+	 * Helper method for allPathsToTarget to be called recursively.
61
+	 *
62
+	 * @todo Implement loop detection
63
+	 * @param Certificate $target
64
+	 * @param CertificateBundle $intermediate
65
+	 * @return array[] Array of arrays containing path certificates
66
+	 */
67
+	private function _resolvePathsToTarget(Certificate $target,
68
+		CertificateBundle $intermediate = null): array
69
+	{
70
+		// array of possible paths
71
+		$paths = array();
72
+		// signed by certificate in the trust list
73
+		foreach ($this->_findIssuers($target, $this->_trustList) as $issuer) {
74
+			// if target is self-signed, path consists of only
75
+			// the target certificate
76
+			if ($target->equals($issuer)) {
77
+				$paths[] = array($target);
78
+			} else {
79
+				$paths[] = array($issuer, $target);
80
+			}
81
+		}
82
+		if (isset($intermediate)) {
83
+			// signed by intermediate certificate
84
+			foreach ($this->_findIssuers($target, $intermediate) as $issuer) {
85
+				// intermediate certificate must not be self-signed
86
+				if ($issuer->isSelfIssued()) {
87
+					continue;
88
+				}
89
+				// resolve paths to issuer
90
+				$subpaths = $this->_resolvePathsToTarget($issuer, $intermediate);
91
+				foreach ($subpaths as $path) {
92
+					$paths[] = array_merge($path, array($target));
93
+				}
94
+			}
95
+		}
96
+		return $paths;
97
+	}
98 98
     
99
-    /**
100
-     * Get shortest path to given target certificate from any trust anchor.
101
-     *
102
-     * @param Certificate $target Target certificate
103
-     * @param CertificateBundle|null $intermediate Optional intermediate
104
-     *        certificates
105
-     * @throws PathBuildingException
106
-     * @return CertificationPath
107
-     */
108
-    public function shortestPathToTarget(Certificate $target,
109
-        CertificateBundle $intermediate = null): CertificationPath
110
-    {
111
-        $paths = $this->allPathsToTarget($target, $intermediate);
112
-        if (!count($paths)) {
113
-            throw new PathBuildingException("No certification paths.");
114
-        }
115
-        usort($paths,
116
-            function ($a, $b) {
117
-                return count($a) < count($b) ? -1 : 1;
118
-            });
119
-        return reset($paths);
120
-    }
99
+	/**
100
+	 * Get shortest path to given target certificate from any trust anchor.
101
+	 *
102
+	 * @param Certificate $target Target certificate
103
+	 * @param CertificateBundle|null $intermediate Optional intermediate
104
+	 *        certificates
105
+	 * @throws PathBuildingException
106
+	 * @return CertificationPath
107
+	 */
108
+	public function shortestPathToTarget(Certificate $target,
109
+		CertificateBundle $intermediate = null): CertificationPath
110
+	{
111
+		$paths = $this->allPathsToTarget($target, $intermediate);
112
+		if (!count($paths)) {
113
+			throw new PathBuildingException("No certification paths.");
114
+		}
115
+		usort($paths,
116
+			function ($a, $b) {
117
+				return count($a) < count($b) ? -1 : 1;
118
+			});
119
+		return reset($paths);
120
+	}
121 121
     
122
-    /**
123
-     * Find all issuers of the target certificate from a given bundle.
124
-     *
125
-     * @param Certificate $target Target certificate
126
-     * @param CertificateBundle $bundle Certificates to search
127
-     * @return Certificate[]
128
-     */
129
-    protected function _findIssuers(Certificate $target,
130
-        CertificateBundle $bundle): array
131
-    {
132
-        $issuers = array();
133
-        $issuer_name = $target->tbsCertificate()->issuer();
134
-        $extensions = $target->tbsCertificate()->extensions();
135
-        // find by authority key identifier
136
-        if ($extensions->hasAuthorityKeyIdentifier()) {
137
-            $ext = $extensions->authorityKeyIdentifier();
138
-            if ($ext->hasKeyIdentifier()) {
139
-                foreach ($bundle->allBySubjectKeyIdentifier(
140
-                    $ext->keyIdentifier()) as $issuer) {
141
-                    // check that issuer name matches
142
-                    if ($issuer->tbsCertificate()
143
-                        ->subject()
144
-                        ->equals($issuer_name)) {
145
-                        $issuers[] = $issuer;
146
-                    }
147
-                }
148
-            }
149
-        }
150
-        return $issuers;
151
-    }
122
+	/**
123
+	 * Find all issuers of the target certificate from a given bundle.
124
+	 *
125
+	 * @param Certificate $target Target certificate
126
+	 * @param CertificateBundle $bundle Certificates to search
127
+	 * @return Certificate[]
128
+	 */
129
+	protected function _findIssuers(Certificate $target,
130
+		CertificateBundle $bundle): array
131
+	{
132
+		$issuers = array();
133
+		$issuer_name = $target->tbsCertificate()->issuer();
134
+		$extensions = $target->tbsCertificate()->extensions();
135
+		// find by authority key identifier
136
+		if ($extensions->hasAuthorityKeyIdentifier()) {
137
+			$ext = $extensions->authorityKeyIdentifier();
138
+			if ($ext->hasKeyIdentifier()) {
139
+				foreach ($bundle->allBySubjectKeyIdentifier(
140
+					$ext->keyIdentifier()) as $issuer) {
141
+					// check that issuer name matches
142
+					if ($issuer->tbsCertificate()
143
+						->subject()
144
+						->equals($issuer_name)) {
145
+						$issuers[] = $issuer;
146
+					}
147
+				}
148
+			}
149
+		}
150
+		return $issuers;
151
+	}
152 152
 }
Please login to merge, or discard this patch.
lib/X509/CertificationRequest/CertificationRequestInfo.php 1 patch
Indentation   +200 added lines, -200 removed lines patch added patch discarded remove patch
@@ -24,204 +24,204 @@
 block discarded – undo
24 24
  */
25 25
 class CertificationRequestInfo
26 26
 {
27
-    const VERSION_1 = 0;
28
-    
29
-    /**
30
-     * Version.
31
-     *
32
-     * @var int
33
-     */
34
-    protected $_version;
35
-    
36
-    /**
37
-     * Subject.
38
-     *
39
-     * @var Name $_subject
40
-     */
41
-    protected $_subject;
42
-    
43
-    /**
44
-     * Public key info.
45
-     *
46
-     * @var PublicKeyInfo $_subjectPKInfo
47
-     */
48
-    protected $_subjectPKInfo;
49
-    
50
-    /**
51
-     * Attributes.
52
-     *
53
-     * @var Attributes|null $_attributes
54
-     */
55
-    protected $_attributes;
56
-    
57
-    /**
58
-     * Constructor.
59
-     *
60
-     * @param Name $subject Subject
61
-     * @param PublicKeyInfo $pkinfo Public key info
62
-     */
63
-    public function __construct(Name $subject, PublicKeyInfo $pkinfo)
64
-    {
65
-        $this->_version = self::VERSION_1;
66
-        $this->_subject = $subject;
67
-        $this->_subjectPKInfo = $pkinfo;
68
-    }
69
-    
70
-    /**
71
-     * Initialize from ASN.1.
72
-     *
73
-     * @param Sequence $seq
74
-     * @throws \UnexpectedValueException
75
-     * @return self
76
-     */
77
-    public static function fromASN1(Sequence $seq): self
78
-    {
79
-        $version = $seq->at(0)
80
-            ->asInteger()
81
-            ->intNumber();
82
-        if ($version != self::VERSION_1) {
83
-            throw new \UnexpectedValueException(
84
-                "Version $version not supported.");
85
-        }
86
-        $subject = Name::fromASN1($seq->at(1)->asSequence());
87
-        $pkinfo = PublicKeyInfo::fromASN1($seq->at(2)->asSequence());
88
-        $obj = new self($subject, $pkinfo);
89
-        if ($seq->hasTagged(0)) {
90
-            $obj->_attributes = Attributes::fromASN1(
91
-                $seq->getTagged(0)
92
-                    ->asImplicit(Element::TYPE_SET)
93
-                    ->asSet());
94
-        }
95
-        return $obj;
96
-    }
97
-    
98
-    /**
99
-     * Get version.
100
-     *
101
-     * @return int
102
-     */
103
-    public function version(): int
104
-    {
105
-        return $this->_version;
106
-    }
107
-    
108
-    /**
109
-     * Get self with subject.
110
-     *
111
-     * @param Name $subject
112
-     * @return self
113
-     */
114
-    public function withSubject(Name $subject): self
115
-    {
116
-        $obj = clone $this;
117
-        $obj->_subject = $subject;
118
-        return $obj;
119
-    }
120
-    
121
-    /**
122
-     * Get subject.
123
-     *
124
-     * @return Name
125
-     */
126
-    public function subject(): Name
127
-    {
128
-        return $this->_subject;
129
-    }
130
-    
131
-    /**
132
-     * Get subject public key info.
133
-     *
134
-     * @return PublicKeyInfo
135
-     */
136
-    public function subjectPKInfo(): PublicKeyInfo
137
-    {
138
-        return $this->_subjectPKInfo;
139
-    }
140
-    
141
-    /**
142
-     * Whether certification request info has attributes.
143
-     *
144
-     * @return bool
145
-     */
146
-    public function hasAttributes(): bool
147
-    {
148
-        return isset($this->_attributes);
149
-    }
150
-    
151
-    /**
152
-     * Get attributes.
153
-     *
154
-     * @throws \LogicException
155
-     * @return Attributes
156
-     */
157
-    public function attributes(): Attributes
158
-    {
159
-        if (!$this->hasAttributes()) {
160
-            throw new \LogicException("No attributes.");
161
-        }
162
-        return $this->_attributes;
163
-    }
164
-    
165
-    /**
166
-     * Get instance of self with attributes.
167
-     *
168
-     * @param Attributes $attribs
169
-     */
170
-    public function withAttributes(Attributes $attribs): self
171
-    {
172
-        $obj = clone $this;
173
-        $obj->_attributes = $attribs;
174
-        return $obj;
175
-    }
176
-    
177
-    /**
178
-     * Get self with extension request attribute.
179
-     *
180
-     * @param Extensions $extensions Extensions to request
181
-     * @return self
182
-     */
183
-    public function withExtensionRequest(Extensions $extensions): self
184
-    {
185
-        $obj = clone $this;
186
-        if (!isset($obj->_attributes)) {
187
-            $obj->_attributes = new Attributes();
188
-        }
189
-        $obj->_attributes = $obj->_attributes->withUnique(
190
-            Attribute::fromAttributeValues(
191
-                new ExtensionRequestValue($extensions)));
192
-        return $obj;
193
-    }
194
-    
195
-    /**
196
-     * Generate ASN.1 structure.
197
-     *
198
-     * @return Sequence
199
-     */
200
-    public function toASN1(): Sequence
201
-    {
202
-        $elements = array(new Integer($this->_version),
203
-            $this->_subject->toASN1(), $this->_subjectPKInfo->toASN1());
204
-        if (isset($this->_attributes)) {
205
-            $elements[] = new ImplicitlyTaggedType(0,
206
-                $this->_attributes->toASN1());
207
-        }
208
-        return new Sequence(...$elements);
209
-    }
210
-    
211
-    /**
212
-     * Create signed CertificationRequest.
213
-     *
214
-     * @param SignatureAlgorithmIdentifier $algo Algorithm used for signing
215
-     * @param PrivateKeyInfo $privkey_info Private key used for signing
216
-     * @param Crypto|null $crypto Crypto engine, use default if not set
217
-     * @return CertificationRequest
218
-     */
219
-    public function sign(SignatureAlgorithmIdentifier $algo,
220
-        PrivateKeyInfo $privkey_info, Crypto $crypto = null): CertificationRequest
221
-    {
222
-        $crypto = $crypto ?: Crypto::getDefault();
223
-        $data = $this->toASN1()->toDER();
224
-        $signature = $crypto->sign($data, $privkey_info, $algo);
225
-        return new CertificationRequest($this, $algo, $signature);
226
-    }
27
+	const VERSION_1 = 0;
28
+    
29
+	/**
30
+	 * Version.
31
+	 *
32
+	 * @var int
33
+	 */
34
+	protected $_version;
35
+    
36
+	/**
37
+	 * Subject.
38
+	 *
39
+	 * @var Name $_subject
40
+	 */
41
+	protected $_subject;
42
+    
43
+	/**
44
+	 * Public key info.
45
+	 *
46
+	 * @var PublicKeyInfo $_subjectPKInfo
47
+	 */
48
+	protected $_subjectPKInfo;
49
+    
50
+	/**
51
+	 * Attributes.
52
+	 *
53
+	 * @var Attributes|null $_attributes
54
+	 */
55
+	protected $_attributes;
56
+    
57
+	/**
58
+	 * Constructor.
59
+	 *
60
+	 * @param Name $subject Subject
61
+	 * @param PublicKeyInfo $pkinfo Public key info
62
+	 */
63
+	public function __construct(Name $subject, PublicKeyInfo $pkinfo)
64
+	{
65
+		$this->_version = self::VERSION_1;
66
+		$this->_subject = $subject;
67
+		$this->_subjectPKInfo = $pkinfo;
68
+	}
69
+    
70
+	/**
71
+	 * Initialize from ASN.1.
72
+	 *
73
+	 * @param Sequence $seq
74
+	 * @throws \UnexpectedValueException
75
+	 * @return self
76
+	 */
77
+	public static function fromASN1(Sequence $seq): self
78
+	{
79
+		$version = $seq->at(0)
80
+			->asInteger()
81
+			->intNumber();
82
+		if ($version != self::VERSION_1) {
83
+			throw new \UnexpectedValueException(
84
+				"Version $version not supported.");
85
+		}
86
+		$subject = Name::fromASN1($seq->at(1)->asSequence());
87
+		$pkinfo = PublicKeyInfo::fromASN1($seq->at(2)->asSequence());
88
+		$obj = new self($subject, $pkinfo);
89
+		if ($seq->hasTagged(0)) {
90
+			$obj->_attributes = Attributes::fromASN1(
91
+				$seq->getTagged(0)
92
+					->asImplicit(Element::TYPE_SET)
93
+					->asSet());
94
+		}
95
+		return $obj;
96
+	}
97
+    
98
+	/**
99
+	 * Get version.
100
+	 *
101
+	 * @return int
102
+	 */
103
+	public function version(): int
104
+	{
105
+		return $this->_version;
106
+	}
107
+    
108
+	/**
109
+	 * Get self with subject.
110
+	 *
111
+	 * @param Name $subject
112
+	 * @return self
113
+	 */
114
+	public function withSubject(Name $subject): self
115
+	{
116
+		$obj = clone $this;
117
+		$obj->_subject = $subject;
118
+		return $obj;
119
+	}
120
+    
121
+	/**
122
+	 * Get subject.
123
+	 *
124
+	 * @return Name
125
+	 */
126
+	public function subject(): Name
127
+	{
128
+		return $this->_subject;
129
+	}
130
+    
131
+	/**
132
+	 * Get subject public key info.
133
+	 *
134
+	 * @return PublicKeyInfo
135
+	 */
136
+	public function subjectPKInfo(): PublicKeyInfo
137
+	{
138
+		return $this->_subjectPKInfo;
139
+	}
140
+    
141
+	/**
142
+	 * Whether certification request info has attributes.
143
+	 *
144
+	 * @return bool
145
+	 */
146
+	public function hasAttributes(): bool
147
+	{
148
+		return isset($this->_attributes);
149
+	}
150
+    
151
+	/**
152
+	 * Get attributes.
153
+	 *
154
+	 * @throws \LogicException
155
+	 * @return Attributes
156
+	 */
157
+	public function attributes(): Attributes
158
+	{
159
+		if (!$this->hasAttributes()) {
160
+			throw new \LogicException("No attributes.");
161
+		}
162
+		return $this->_attributes;
163
+	}
164
+    
165
+	/**
166
+	 * Get instance of self with attributes.
167
+	 *
168
+	 * @param Attributes $attribs
169
+	 */
170
+	public function withAttributes(Attributes $attribs): self
171
+	{
172
+		$obj = clone $this;
173
+		$obj->_attributes = $attribs;
174
+		return $obj;
175
+	}
176
+    
177
+	/**
178
+	 * Get self with extension request attribute.
179
+	 *
180
+	 * @param Extensions $extensions Extensions to request
181
+	 * @return self
182
+	 */
183
+	public function withExtensionRequest(Extensions $extensions): self
184
+	{
185
+		$obj = clone $this;
186
+		if (!isset($obj->_attributes)) {
187
+			$obj->_attributes = new Attributes();
188
+		}
189
+		$obj->_attributes = $obj->_attributes->withUnique(
190
+			Attribute::fromAttributeValues(
191
+				new ExtensionRequestValue($extensions)));
192
+		return $obj;
193
+	}
194
+    
195
+	/**
196
+	 * Generate ASN.1 structure.
197
+	 *
198
+	 * @return Sequence
199
+	 */
200
+	public function toASN1(): Sequence
201
+	{
202
+		$elements = array(new Integer($this->_version),
203
+			$this->_subject->toASN1(), $this->_subjectPKInfo->toASN1());
204
+		if (isset($this->_attributes)) {
205
+			$elements[] = new ImplicitlyTaggedType(0,
206
+				$this->_attributes->toASN1());
207
+		}
208
+		return new Sequence(...$elements);
209
+	}
210
+    
211
+	/**
212
+	 * Create signed CertificationRequest.
213
+	 *
214
+	 * @param SignatureAlgorithmIdentifier $algo Algorithm used for signing
215
+	 * @param PrivateKeyInfo $privkey_info Private key used for signing
216
+	 * @param Crypto|null $crypto Crypto engine, use default if not set
217
+	 * @return CertificationRequest
218
+	 */
219
+	public function sign(SignatureAlgorithmIdentifier $algo,
220
+		PrivateKeyInfo $privkey_info, Crypto $crypto = null): CertificationRequest
221
+	{
222
+		$crypto = $crypto ?: Crypto::getDefault();
223
+		$data = $this->toASN1()->toDER();
224
+		$signature = $crypto->sign($data, $privkey_info, $algo);
225
+		return new CertificationRequest($this, $algo, $signature);
226
+	}
227 227
 }
Please login to merge, or discard this patch.
lib/X509/CertificationRequest/CertificationRequest.php 1 patch
Indentation   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -18,172 +18,172 @@
 block discarded – undo
18 18
  */
19 19
 class CertificationRequest
20 20
 {
21
-    /**
22
-     * Certification request info.
23
-     *
24
-     * @var CertificationRequestInfo $_certificationRequestInfo
25
-     */
26
-    protected $_certificationRequestInfo;
21
+	/**
22
+	 * Certification request info.
23
+	 *
24
+	 * @var CertificationRequestInfo $_certificationRequestInfo
25
+	 */
26
+	protected $_certificationRequestInfo;
27 27
     
28
-    /**
29
-     * Signature algorithm.
30
-     *
31
-     * @var SignatureAlgorithmIdentifier $_signatureAlgorithm
32
-     */
33
-    protected $_signatureAlgorithm;
28
+	/**
29
+	 * Signature algorithm.
30
+	 *
31
+	 * @var SignatureAlgorithmIdentifier $_signatureAlgorithm
32
+	 */
33
+	protected $_signatureAlgorithm;
34 34
     
35
-    /**
36
-     * Signature.
37
-     *
38
-     * @var Signature $_signature
39
-     */
40
-    protected $_signature;
35
+	/**
36
+	 * Signature.
37
+	 *
38
+	 * @var Signature $_signature
39
+	 */
40
+	protected $_signature;
41 41
     
42
-    /**
43
-     * Constructor.
44
-     *
45
-     * @param CertificationRequestInfo $info
46
-     * @param SignatureAlgorithmIdentifier $algo
47
-     * @param Signature $signature
48
-     */
49
-    public function __construct(CertificationRequestInfo $info,
50
-        SignatureAlgorithmIdentifier $algo, Signature $signature)
51
-    {
52
-        $this->_certificationRequestInfo = $info;
53
-        $this->_signatureAlgorithm = $algo;
54
-        $this->_signature = $signature;
55
-    }
42
+	/**
43
+	 * Constructor.
44
+	 *
45
+	 * @param CertificationRequestInfo $info
46
+	 * @param SignatureAlgorithmIdentifier $algo
47
+	 * @param Signature $signature
48
+	 */
49
+	public function __construct(CertificationRequestInfo $info,
50
+		SignatureAlgorithmIdentifier $algo, Signature $signature)
51
+	{
52
+		$this->_certificationRequestInfo = $info;
53
+		$this->_signatureAlgorithm = $algo;
54
+		$this->_signature = $signature;
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
-        $info = CertificationRequestInfo::fromASN1($seq->at(0)->asSequence());
66
-        $algo = AlgorithmIdentifier::fromASN1($seq->at(1)->asSequence());
67
-        if (!$algo instanceof SignatureAlgorithmIdentifier) {
68
-            throw new \UnexpectedValueException(
69
-                "Unsupported signature algorithm " . $algo->oid() . ".");
70
-        }
71
-        $signature = Signature::fromSignatureData(
72
-            $seq->at(2)
73
-                ->asBitString()
74
-                ->string(), $algo);
75
-        return new self($info, $algo, $signature);
76
-    }
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
+		$info = CertificationRequestInfo::fromASN1($seq->at(0)->asSequence());
66
+		$algo = AlgorithmIdentifier::fromASN1($seq->at(1)->asSequence());
67
+		if (!$algo instanceof SignatureAlgorithmIdentifier) {
68
+			throw new \UnexpectedValueException(
69
+				"Unsupported signature algorithm " . $algo->oid() . ".");
70
+		}
71
+		$signature = Signature::fromSignatureData(
72
+			$seq->at(2)
73
+				->asBitString()
74
+				->string(), $algo);
75
+		return new self($info, $algo, $signature);
76
+	}
77 77
     
78
-    /**
79
-     * Initialize from DER.
80
-     *
81
-     * @param string $data
82
-     * @return self
83
-     */
84
-    public static function fromDER(string $data): self
85
-    {
86
-        return self::fromASN1(Sequence::fromDER($data));
87
-    }
78
+	/**
79
+	 * Initialize from DER.
80
+	 *
81
+	 * @param string $data
82
+	 * @return self
83
+	 */
84
+	public static function fromDER(string $data): self
85
+	{
86
+		return self::fromASN1(Sequence::fromDER($data));
87
+	}
88 88
     
89
-    /**
90
-     * Initialize from PEM.
91
-     *
92
-     * @param PEM $pem
93
-     * @throws \UnexpectedValueException
94
-     * @return self
95
-     */
96
-    public static function fromPEM(PEM $pem): self
97
-    {
98
-        if ($pem->type() !== PEM::TYPE_CERTIFICATE_REQUEST) {
99
-            throw new \UnexpectedValueException("Invalid PEM type.");
100
-        }
101
-        return self::fromDER($pem->data());
102
-    }
89
+	/**
90
+	 * Initialize from PEM.
91
+	 *
92
+	 * @param PEM $pem
93
+	 * @throws \UnexpectedValueException
94
+	 * @return self
95
+	 */
96
+	public static function fromPEM(PEM $pem): self
97
+	{
98
+		if ($pem->type() !== PEM::TYPE_CERTIFICATE_REQUEST) {
99
+			throw new \UnexpectedValueException("Invalid PEM type.");
100
+		}
101
+		return self::fromDER($pem->data());
102
+	}
103 103
     
104
-    /**
105
-     * Get certification request info.
106
-     *
107
-     * @return CertificationRequestInfo
108
-     */
109
-    public function certificationRequestInfo(): CertificationRequestInfo
110
-    {
111
-        return $this->_certificationRequestInfo;
112
-    }
104
+	/**
105
+	 * Get certification request info.
106
+	 *
107
+	 * @return CertificationRequestInfo
108
+	 */
109
+	public function certificationRequestInfo(): CertificationRequestInfo
110
+	{
111
+		return $this->_certificationRequestInfo;
112
+	}
113 113
     
114
-    /**
115
-     * Get signature algorithm.
116
-     *
117
-     * @return SignatureAlgorithmIdentifier
118
-     */
119
-    public function signatureAlgorithm(): SignatureAlgorithmIdentifier
120
-    {
121
-        return $this->_signatureAlgorithm;
122
-    }
114
+	/**
115
+	 * Get signature algorithm.
116
+	 *
117
+	 * @return SignatureAlgorithmIdentifier
118
+	 */
119
+	public function signatureAlgorithm(): SignatureAlgorithmIdentifier
120
+	{
121
+		return $this->_signatureAlgorithm;
122
+	}
123 123
     
124
-    /**
125
-     * Get signature.
126
-     *
127
-     * @return Signature
128
-     */
129
-    public function signature(): Signature
130
-    {
131
-        return $this->_signature;
132
-    }
124
+	/**
125
+	 * Get signature.
126
+	 *
127
+	 * @return Signature
128
+	 */
129
+	public function signature(): Signature
130
+	{
131
+		return $this->_signature;
132
+	}
133 133
     
134
-    /**
135
-     * Generate ASN.1 structure.
136
-     *
137
-     * @return Sequence
138
-     */
139
-    public function toASN1(): Sequence
140
-    {
141
-        return new Sequence($this->_certificationRequestInfo->toASN1(),
142
-            $this->_signatureAlgorithm->toASN1(), $this->_signature->bitString());
143
-    }
134
+	/**
135
+	 * Generate ASN.1 structure.
136
+	 *
137
+	 * @return Sequence
138
+	 */
139
+	public function toASN1(): Sequence
140
+	{
141
+		return new Sequence($this->_certificationRequestInfo->toASN1(),
142
+			$this->_signatureAlgorithm->toASN1(), $this->_signature->bitString());
143
+	}
144 144
     
145
-    /**
146
-     * Get certification request as a DER.
147
-     *
148
-     * @return string
149
-     */
150
-    public function toDER(): string
151
-    {
152
-        return $this->toASN1()->toDER();
153
-    }
145
+	/**
146
+	 * Get certification request as a DER.
147
+	 *
148
+	 * @return string
149
+	 */
150
+	public function toDER(): string
151
+	{
152
+		return $this->toASN1()->toDER();
153
+	}
154 154
     
155
-    /**
156
-     * Get certification request as a PEM.
157
-     *
158
-     * @return PEM
159
-     */
160
-    public function toPEM(): PEM
161
-    {
162
-        return new PEM(PEM::TYPE_CERTIFICATE_REQUEST, $this->toDER());
163
-    }
155
+	/**
156
+	 * Get certification request as a PEM.
157
+	 *
158
+	 * @return PEM
159
+	 */
160
+	public function toPEM(): PEM
161
+	{
162
+		return new PEM(PEM::TYPE_CERTIFICATE_REQUEST, $this->toDER());
163
+	}
164 164
     
165
-    /**
166
-     * Verify certification request signature.
167
-     *
168
-     * @param Crypto|null $crypto Crypto engine, use default if not set
169
-     * @return bool True if signature matches
170
-     */
171
-    public function verify(Crypto $crypto = null): bool
172
-    {
173
-        $crypto = $crypto ?: Crypto::getDefault();
174
-        $data = $this->_certificationRequestInfo->toASN1()->toDER();
175
-        $pk_info = $this->_certificationRequestInfo->subjectPKInfo();
176
-        return $crypto->verify($data, $this->_signature, $pk_info,
177
-            $this->_signatureAlgorithm);
178
-    }
165
+	/**
166
+	 * Verify certification request signature.
167
+	 *
168
+	 * @param Crypto|null $crypto Crypto engine, use default if not set
169
+	 * @return bool True if signature matches
170
+	 */
171
+	public function verify(Crypto $crypto = null): bool
172
+	{
173
+		$crypto = $crypto ?: Crypto::getDefault();
174
+		$data = $this->_certificationRequestInfo->toASN1()->toDER();
175
+		$pk_info = $this->_certificationRequestInfo->subjectPKInfo();
176
+		return $crypto->verify($data, $this->_signature, $pk_info,
177
+			$this->_signatureAlgorithm);
178
+	}
179 179
     
180
-    /**
181
-     * Get certification request as a PEM formatted string.
182
-     *
183
-     * @return string
184
-     */
185
-    public function __toString()
186
-    {
187
-        return $this->toPEM()->string();
188
-    }
180
+	/**
181
+	 * Get certification request as a PEM formatted string.
182
+	 *
183
+	 * @return string
184
+	 */
185
+	public function __toString()
186
+	{
187
+		return $this->toPEM()->string();
188
+	}
189 189
 }
Please login to merge, or discard this patch.
lib/X509/CertificationRequest/Attribute/ExtensionRequestValue.php 1 patch
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -17,94 +17,94 @@
 block discarded – undo
17 17
  */
18 18
 class ExtensionRequestValue extends AttributeValue
19 19
 {
20
-    const OID = "1.2.840.113549.1.9.14";
20
+	const OID = "1.2.840.113549.1.9.14";
21 21
     
22
-    /**
23
-     * Extensions.
24
-     *
25
-     * @var Extensions $_extensions
26
-     */
27
-    protected $_extensions;
22
+	/**
23
+	 * Extensions.
24
+	 *
25
+	 * @var Extensions $_extensions
26
+	 */
27
+	protected $_extensions;
28 28
     
29
-    /**
30
-     * Constructor.
31
-     *
32
-     * @param Extensions $extensions
33
-     */
34
-    public function __construct(Extensions $extensions)
35
-    {
36
-        $this->_extensions = $extensions;
37
-        $this->_oid = self::OID;
38
-    }
29
+	/**
30
+	 * Constructor.
31
+	 *
32
+	 * @param Extensions $extensions
33
+	 */
34
+	public function __construct(Extensions $extensions)
35
+	{
36
+		$this->_extensions = $extensions;
37
+		$this->_oid = self::OID;
38
+	}
39 39
     
40
-    /**
41
-     *
42
-     * @see \X501\ASN1\AttributeValue\AttributeValue::fromASN1()
43
-     * @param UnspecifiedType $el
44
-     * @return self
45
-     */
46
-    public static function fromASN1(UnspecifiedType $el): self
47
-    {
48
-        return new self(Extensions::fromASN1($el->asSequence()));
49
-    }
40
+	/**
41
+	 *
42
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::fromASN1()
43
+	 * @param UnspecifiedType $el
44
+	 * @return self
45
+	 */
46
+	public static function fromASN1(UnspecifiedType $el): self
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
-     *
63
-     * @see \X501\ASN1\AttributeValue\AttributeValue::toASN1()
64
-     * @return Sequence
65
-     */
66
-    public function toASN1(): Sequence
67
-    {
68
-        return $this->_extensions->toASN1();
69
-    }
61
+	/**
62
+	 *
63
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::toASN1()
64
+	 * @return Sequence
65
+	 */
66
+	public function toASN1(): Sequence
67
+	{
68
+		return $this->_extensions->toASN1();
69
+	}
70 70
     
71
-    /**
72
-     *
73
-     * @see \X501\ASN1\AttributeValue\AttributeValue::stringValue()
74
-     * @return string
75
-     */
76
-    public function stringValue(): string
77
-    {
78
-        return "#" . bin2hex($this->toASN1()->toDER());
79
-    }
71
+	/**
72
+	 *
73
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::stringValue()
74
+	 * @return string
75
+	 */
76
+	public function stringValue(): string
77
+	{
78
+		return "#" . bin2hex($this->toASN1()->toDER());
79
+	}
80 80
     
81
-    /**
82
-     *
83
-     * @see \X501\ASN1\AttributeValue\AttributeValue::equalityMatchingRule()
84
-     * @return BinaryMatch
85
-     */
86
-    public function equalityMatchingRule(): BinaryMatch
87
-    {
88
-        return new BinaryMatch();
89
-    }
81
+	/**
82
+	 *
83
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::equalityMatchingRule()
84
+	 * @return BinaryMatch
85
+	 */
86
+	public function equalityMatchingRule(): BinaryMatch
87
+	{
88
+		return new BinaryMatch();
89
+	}
90 90
     
91
-    /**
92
-     *
93
-     * @see \X501\ASN1\AttributeValue\AttributeValue::rfc2253String()
94
-     * @return string
95
-     */
96
-    public function rfc2253String(): string
97
-    {
98
-        return $this->stringValue();
99
-    }
91
+	/**
92
+	 *
93
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::rfc2253String()
94
+	 * @return string
95
+	 */
96
+	public function rfc2253String(): string
97
+	{
98
+		return $this->stringValue();
99
+	}
100 100
     
101
-    /**
102
-     *
103
-     * @see \X501\ASN1\AttributeValue\AttributeValue::_transcodedString()
104
-     * @return string
105
-     */
106
-    protected function _transcodedString(): string
107
-    {
108
-        return $this->stringValue();
109
-    }
101
+	/**
102
+	 *
103
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::_transcodedString()
104
+	 * @return string
105
+	 */
106
+	protected function _transcodedString(): string
107
+	{
108
+		return $this->stringValue();
109
+	}
110 110
 }
Please login to merge, or discard this patch.
lib/X509/CertificationRequest/Attributes.php 1 patch
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -20,107 +20,107 @@
 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 = array(
33
-        /* @formatter:off */
34
-        ExtensionRequestValue::OID => ExtensionRequestValue::class
35
-        /* @formatter:on */
36
-    );
25
+	/**
26
+	 * Mapping from OID to attribute value class name.
27
+	 *
28
+	 * @internal
29
+	 *
30
+	 * @var array
31
+	 */
32
+	const MAP_OID_TO_CLASS = array(
33
+		/* @formatter:off */
34
+		ExtensionRequestValue::OID => ExtensionRequestValue::class
35
+		/* @formatter:on */
36
+	);
37 37
     
38
-    /**
39
-     * Constructor.
40
-     *
41
-     * @param Attribute ...$attribs Attribute objects
42
-     */
43
-    public function __construct(Attribute ...$attribs)
44
-    {
45
-        $this->_attributes = $attribs;
46
-    }
38
+	/**
39
+	 * Constructor.
40
+	 *
41
+	 * @param Attribute ...$attribs Attribute objects
42
+	 */
43
+	public function __construct(Attribute ...$attribs)
44
+	{
45
+		$this->_attributes = $attribs;
46
+	}
47 47
     
48
-    /**
49
-     * Initialize from attribute values.
50
-     *
51
-     * @param AttributeValue ...$values
52
-     * @return self
53
-     */
54
-    public static function fromAttributeValues(AttributeValue ...$values): self
55
-    {
56
-        $attribs = array_map(
57
-            function (AttributeValue $value) {
58
-                return $value->toAttribute();
59
-            }, $values);
60
-        return new self(...$attribs);
61
-    }
48
+	/**
49
+	 * Initialize from attribute values.
50
+	 *
51
+	 * @param AttributeValue ...$values
52
+	 * @return self
53
+	 */
54
+	public static function fromAttributeValues(AttributeValue ...$values): self
55
+	{
56
+		$attribs = array_map(
57
+			function (AttributeValue $value) {
58
+				return $value->toAttribute();
59
+			}, $values);
60
+		return new self(...$attribs);
61
+	}
62 62
     
63
-    /**
64
-     * Initialize from ASN.1.
65
-     *
66
-     * @param Set $set
67
-     * @return self
68
-     */
69
-    public static function fromASN1(Set $set): self
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
-    }
63
+	/**
64
+	 * Initialize from ASN.1.
65
+	 *
66
+	 * @param Set $set
67
+	 * @return self
68
+	 */
69
+	public static function fromASN1(Set $set): self
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
-     * @return ExtensionRequestValue
103
-     */
104
-    public function extensionRequest(): ExtensionRequestValue
105
-    {
106
-        if (!$this->hasExtensionRequest()) {
107
-            throw new \LogicException("No extension request attribute.");
108
-        }
109
-        return $this->firstOf(ExtensionRequestValue::OID)->first();
110
-    }
98
+	/**
99
+	 * Get extension request attribute value.
100
+	 *
101
+	 * @throws \LogicException
102
+	 * @return ExtensionRequestValue
103
+	 */
104
+	public function extensionRequest(): ExtensionRequestValue
105
+	{
106
+		if (!$this->hasExtensionRequest()) {
107
+			throw new \LogicException("No extension request attribute.");
108
+		}
109
+		return $this->firstOf(ExtensionRequestValue::OID)->first();
110
+	}
111 111
     
112
-    /**
113
-     * Generate ASN.1 structure.
114
-     *
115
-     * @return Set
116
-     */
117
-    public function toASN1(): Set
118
-    {
119
-        $elements = array_map(
120
-            function (Attribute $attr) {
121
-                return $attr->toASN1();
122
-            }, array_values($this->_attributes));
123
-        $set = new Set(...$elements);
124
-        return $set->sortedSetOf();
125
-    }
112
+	/**
113
+	 * Generate ASN.1 structure.
114
+	 *
115
+	 * @return Set
116
+	 */
117
+	public function toASN1(): Set
118
+	{
119
+		$elements = array_map(
120
+			function (Attribute $attr) {
121
+				return $attr->toASN1();
122
+			}, array_values($this->_attributes));
123
+		$set = new Set(...$elements);
124
+		return $set->sortedSetOf();
125
+	}
126 126
 }
Please login to merge, or discard this patch.