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 ( ff3a63...584877 )
by Joni
04:52
created
lib/X509/Certificate/Extension/KeyUsageExtension.php 1 patch
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -12,155 +12,155 @@
 block discarded – undo
12 12
  */
13 13
 class KeyUsageExtension extends Extension
14 14
 {
15
-    const DIGITAL_SIGNATURE = 0x100;
16
-    const NON_REPUDIATION = 0x080;
17
-    const KEY_ENCIPHERMENT = 0x040;
18
-    const DATA_ENCIPHERMENT = 0x020;
19
-    const KEY_AGREEMENT = 0x010;
20
-    const KEY_CERT_SIGN = 0x008;
21
-    const CRL_SIGN = 0x004;
22
-    const ENCIPHER_ONLY = 0x002;
23
-    const DECIPHER_ONLY = 0x001;
15
+	const DIGITAL_SIGNATURE = 0x100;
16
+	const NON_REPUDIATION = 0x080;
17
+	const KEY_ENCIPHERMENT = 0x040;
18
+	const DATA_ENCIPHERMENT = 0x020;
19
+	const KEY_AGREEMENT = 0x010;
20
+	const KEY_CERT_SIGN = 0x008;
21
+	const CRL_SIGN = 0x004;
22
+	const ENCIPHER_ONLY = 0x002;
23
+	const DECIPHER_ONLY = 0x001;
24 24
     
25
-    /**
26
-     * Key usage flags.
27
-     *
28
-     * @var int $_keyUsage
29
-     */
30
-    protected $_keyUsage;
25
+	/**
26
+	 * Key usage flags.
27
+	 *
28
+	 * @var int $_keyUsage
29
+	 */
30
+	protected $_keyUsage;
31 31
     
32
-    /**
33
-     * Constructor.
34
-     *
35
-     * @param bool $critical
36
-     * @param int $keyUsage
37
-     */
38
-    public function __construct($critical, $keyUsage)
39
-    {
40
-        parent::__construct(self::OID_KEY_USAGE, $critical);
41
-        $this->_keyUsage = (int) $keyUsage;
42
-    }
32
+	/**
33
+	 * Constructor.
34
+	 *
35
+	 * @param bool $critical
36
+	 * @param int $keyUsage
37
+	 */
38
+	public function __construct($critical, $keyUsage)
39
+	{
40
+		parent::__construct(self::OID_KEY_USAGE, $critical);
41
+		$this->_keyUsage = (int) $keyUsage;
42
+	}
43 43
     
44
-    /**
45
-     *
46
-     * {@inheritdoc}
47
-     * @return self
48
-     */
49
-    protected static function _fromDER($data, $critical)
50
-    {
51
-        return new self($critical,
52
-            Flags::fromBitString(BitString::fromDER($data), 9)->number());
53
-    }
44
+	/**
45
+	 *
46
+	 * {@inheritdoc}
47
+	 * @return self
48
+	 */
49
+	protected static function _fromDER($data, $critical)
50
+	{
51
+		return new self($critical,
52
+			Flags::fromBitString(BitString::fromDER($data), 9)->number());
53
+	}
54 54
     
55
-    /**
56
-     * Check whether digitalSignature flag is set.
57
-     *
58
-     * @return bool
59
-     */
60
-    public function isDigitalSignature()
61
-    {
62
-        return $this->_flagSet(self::DIGITAL_SIGNATURE);
63
-    }
55
+	/**
56
+	 * Check whether digitalSignature flag is set.
57
+	 *
58
+	 * @return bool
59
+	 */
60
+	public function isDigitalSignature()
61
+	{
62
+		return $this->_flagSet(self::DIGITAL_SIGNATURE);
63
+	}
64 64
     
65
-    /**
66
-     * Check whether nonRepudiation/contentCommitment flag is set.
67
-     *
68
-     * @return bool
69
-     */
70
-    public function isNonRepudiation()
71
-    {
72
-        return $this->_flagSet(self::NON_REPUDIATION);
73
-    }
65
+	/**
66
+	 * Check whether nonRepudiation/contentCommitment flag is set.
67
+	 *
68
+	 * @return bool
69
+	 */
70
+	public function isNonRepudiation()
71
+	{
72
+		return $this->_flagSet(self::NON_REPUDIATION);
73
+	}
74 74
     
75
-    /**
76
-     * Check whether keyEncipherment flag is set.
77
-     *
78
-     * @return bool
79
-     */
80
-    public function isKeyEncipherment()
81
-    {
82
-        return $this->_flagSet(self::KEY_ENCIPHERMENT);
83
-    }
75
+	/**
76
+	 * Check whether keyEncipherment flag is set.
77
+	 *
78
+	 * @return bool
79
+	 */
80
+	public function isKeyEncipherment()
81
+	{
82
+		return $this->_flagSet(self::KEY_ENCIPHERMENT);
83
+	}
84 84
     
85
-    /**
86
-     * Check whether dataEncipherment flag is set.
87
-     *
88
-     * @return bool
89
-     */
90
-    public function isDataEncipherment()
91
-    {
92
-        return $this->_flagSet(self::DATA_ENCIPHERMENT);
93
-    }
85
+	/**
86
+	 * Check whether dataEncipherment flag is set.
87
+	 *
88
+	 * @return bool
89
+	 */
90
+	public function isDataEncipherment()
91
+	{
92
+		return $this->_flagSet(self::DATA_ENCIPHERMENT);
93
+	}
94 94
     
95
-    /**
96
-     * Check whether keyAgreement flag is set.
97
-     *
98
-     * @return bool
99
-     */
100
-    public function isKeyAgreement()
101
-    {
102
-        return $this->_flagSet(self::KEY_AGREEMENT);
103
-    }
95
+	/**
96
+	 * Check whether keyAgreement flag is set.
97
+	 *
98
+	 * @return bool
99
+	 */
100
+	public function isKeyAgreement()
101
+	{
102
+		return $this->_flagSet(self::KEY_AGREEMENT);
103
+	}
104 104
     
105
-    /**
106
-     * Check whether keyCertSign flag is set.
107
-     *
108
-     * @return bool
109
-     */
110
-    public function isKeyCertSign()
111
-    {
112
-        return $this->_flagSet(self::KEY_CERT_SIGN);
113
-    }
105
+	/**
106
+	 * Check whether keyCertSign flag is set.
107
+	 *
108
+	 * @return bool
109
+	 */
110
+	public function isKeyCertSign()
111
+	{
112
+		return $this->_flagSet(self::KEY_CERT_SIGN);
113
+	}
114 114
     
115
-    /**
116
-     * Check whether cRLSign flag is set.
117
-     *
118
-     * @return bool
119
-     */
120
-    public function isCRLSign()
121
-    {
122
-        return $this->_flagSet(self::CRL_SIGN);
123
-    }
115
+	/**
116
+	 * Check whether cRLSign flag is set.
117
+	 *
118
+	 * @return bool
119
+	 */
120
+	public function isCRLSign()
121
+	{
122
+		return $this->_flagSet(self::CRL_SIGN);
123
+	}
124 124
     
125
-    /**
126
-     * Check whether encipherOnly flag is set.
127
-     *
128
-     * @return bool
129
-     */
130
-    public function isEncipherOnly()
131
-    {
132
-        return $this->_flagSet(self::ENCIPHER_ONLY);
133
-    }
125
+	/**
126
+	 * Check whether encipherOnly flag is set.
127
+	 *
128
+	 * @return bool
129
+	 */
130
+	public function isEncipherOnly()
131
+	{
132
+		return $this->_flagSet(self::ENCIPHER_ONLY);
133
+	}
134 134
     
135
-    /**
136
-     * Check whether decipherOnly flag is set.
137
-     *
138
-     * @return bool
139
-     */
140
-    public function isDecipherOnly()
141
-    {
142
-        return $this->_flagSet(self::DECIPHER_ONLY);
143
-    }
135
+	/**
136
+	 * Check whether decipherOnly flag is set.
137
+	 *
138
+	 * @return bool
139
+	 */
140
+	public function isDecipherOnly()
141
+	{
142
+		return $this->_flagSet(self::DECIPHER_ONLY);
143
+	}
144 144
     
145
-    /**
146
-     * Check whether given flag is set.
147
-     *
148
-     * @param int $flag
149
-     * @return boolean
150
-     */
151
-    protected function _flagSet($flag)
152
-    {
153
-        return (bool) ($this->_keyUsage & $flag);
154
-    }
145
+	/**
146
+	 * Check whether given flag is set.
147
+	 *
148
+	 * @param int $flag
149
+	 * @return boolean
150
+	 */
151
+	protected function _flagSet($flag)
152
+	{
153
+		return (bool) ($this->_keyUsage & $flag);
154
+	}
155 155
     
156
-    /**
157
-     *
158
-     * {@inheritdoc}
159
-     * @return BitString
160
-     */
161
-    protected function _valueASN1()
162
-    {
163
-        $flags = new Flags($this->_keyUsage, 9);
164
-        return $flags->bitString()->withoutTrailingZeroes();
165
-    }
156
+	/**
157
+	 *
158
+	 * {@inheritdoc}
159
+	 * @return BitString
160
+	 */
161
+	protected function _valueASN1()
162
+	{
163
+		$flags = new Flags($this->_keyUsage, 9);
164
+		return $flags->bitString()->withoutTrailingZeroes();
165
+	}
166 166
 }
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/CertificatePoliciesExtension.php 1 patch
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -12,136 +12,136 @@
 block discarded – undo
12 12
  * @link https://tools.ietf.org/html/rfc5280#section-4.2.1.4
13 13
  */
14 14
 class CertificatePoliciesExtension extends Extension implements 
15
-    \Countable,
16
-    \IteratorAggregate
15
+	\Countable,
16
+	\IteratorAggregate
17 17
 {
18
-    /**
19
-     * Policy information terms.
20
-     *
21
-     * @var PolicyInformation[] $_policies
22
-     */
23
-    protected $_policies;
18
+	/**
19
+	 * Policy information terms.
20
+	 *
21
+	 * @var PolicyInformation[] $_policies
22
+	 */
23
+	protected $_policies;
24 24
     
25
-    /**
26
-     * Constructor.
27
-     *
28
-     * @param bool $critical
29
-     * @param PolicyInformation ...$policies
30
-     */
31
-    public function __construct($critical, PolicyInformation ...$policies)
32
-    {
33
-        parent::__construct(Extension::OID_CERTIFICATE_POLICIES, $critical);
34
-        $this->_policies = array();
35
-        foreach ($policies as $policy) {
36
-            $this->_policies[$policy->oid()] = $policy;
37
-        }
38
-    }
25
+	/**
26
+	 * Constructor.
27
+	 *
28
+	 * @param bool $critical
29
+	 * @param PolicyInformation ...$policies
30
+	 */
31
+	public function __construct($critical, PolicyInformation ...$policies)
32
+	{
33
+		parent::__construct(Extension::OID_CERTIFICATE_POLICIES, $critical);
34
+		$this->_policies = array();
35
+		foreach ($policies as $policy) {
36
+			$this->_policies[$policy->oid()] = $policy;
37
+		}
38
+	}
39 39
     
40
-    /**
41
-     *
42
-     * {@inheritdoc}
43
-     * @return self
44
-     */
45
-    protected static function _fromDER($data, $critical)
46
-    {
47
-        $policies = array_map(
48
-            function (UnspecifiedType $el) {
49
-                return PolicyInformation::fromASN1($el->asSequence());
50
-            }, Sequence::fromDER($data)->elements());
51
-        if (!count($policies)) {
52
-            throw new \UnexpectedValueException(
53
-                "certificatePolicies must contain" .
54
-                     " at least one PolicyInformation.");
55
-        }
56
-        return new self($critical, ...$policies);
57
-    }
40
+	/**
41
+	 *
42
+	 * {@inheritdoc}
43
+	 * @return self
44
+	 */
45
+	protected static function _fromDER($data, $critical)
46
+	{
47
+		$policies = array_map(
48
+			function (UnspecifiedType $el) {
49
+				return PolicyInformation::fromASN1($el->asSequence());
50
+			}, Sequence::fromDER($data)->elements());
51
+		if (!count($policies)) {
52
+			throw new \UnexpectedValueException(
53
+				"certificatePolicies must contain" .
54
+					 " at least one PolicyInformation.");
55
+		}
56
+		return new self($critical, ...$policies);
57
+	}
58 58
     
59
-    /**
60
-     * Check whether policy information by OID is present.
61
-     *
62
-     * @param string $oid
63
-     * @return bool
64
-     */
65
-    public function has($oid)
66
-    {
67
-        return isset($this->_policies[$oid]);
68
-    }
59
+	/**
60
+	 * Check whether policy information by OID is present.
61
+	 *
62
+	 * @param string $oid
63
+	 * @return bool
64
+	 */
65
+	public function has($oid)
66
+	{
67
+		return isset($this->_policies[$oid]);
68
+	}
69 69
     
70
-    /**
71
-     * Get policy information by OID.
72
-     *
73
-     * @param string $oid
74
-     * @throws \LogicException
75
-     * @return PolicyInformation
76
-     */
77
-    public function get($oid)
78
-    {
79
-        if (!$this->has($oid)) {
80
-            throw new \LogicException("Not certificate policy by OID $oid.");
81
-        }
82
-        return $this->_policies[$oid];
83
-    }
70
+	/**
71
+	 * Get policy information by OID.
72
+	 *
73
+	 * @param string $oid
74
+	 * @throws \LogicException
75
+	 * @return PolicyInformation
76
+	 */
77
+	public function get($oid)
78
+	{
79
+		if (!$this->has($oid)) {
80
+			throw new \LogicException("Not certificate policy by OID $oid.");
81
+		}
82
+		return $this->_policies[$oid];
83
+	}
84 84
     
85
-    /**
86
-     * Check whether anyPolicy is present.
87
-     *
88
-     * @return bool
89
-     */
90
-    public function hasAnyPolicy()
91
-    {
92
-        return $this->has(PolicyInformation::OID_ANY_POLICY);
93
-    }
85
+	/**
86
+	 * Check whether anyPolicy is present.
87
+	 *
88
+	 * @return bool
89
+	 */
90
+	public function hasAnyPolicy()
91
+	{
92
+		return $this->has(PolicyInformation::OID_ANY_POLICY);
93
+	}
94 94
     
95
-    /**
96
-     * Get anyPolicy information.
97
-     *
98
-     * @throws \LogicException If anyPolicy is not present.
99
-     * @return PolicyInformation
100
-     */
101
-    public function anyPolicy()
102
-    {
103
-        if (!$this->hasAnyPolicy()) {
104
-            throw new \LogicException("No anyPolicy.");
105
-        }
106
-        return $this->get(PolicyInformation::OID_ANY_POLICY);
107
-    }
95
+	/**
96
+	 * Get anyPolicy information.
97
+	 *
98
+	 * @throws \LogicException If anyPolicy is not present.
99
+	 * @return PolicyInformation
100
+	 */
101
+	public function anyPolicy()
102
+	{
103
+		if (!$this->hasAnyPolicy()) {
104
+			throw new \LogicException("No anyPolicy.");
105
+		}
106
+		return $this->get(PolicyInformation::OID_ANY_POLICY);
107
+	}
108 108
     
109
-    /**
110
-     *
111
-     * {@inheritdoc}
112
-     * @return Sequence
113
-     */
114
-    protected function _valueASN1()
115
-    {
116
-        if (!count($this->_policies)) {
117
-            throw new \LogicException("No policies.");
118
-        }
119
-        $elements = array_map(
120
-            function (PolicyInformation $pi) {
121
-                return $pi->toASN1();
122
-            }, array_values($this->_policies));
123
-        return new Sequence(...$elements);
124
-    }
109
+	/**
110
+	 *
111
+	 * {@inheritdoc}
112
+	 * @return Sequence
113
+	 */
114
+	protected function _valueASN1()
115
+	{
116
+		if (!count($this->_policies)) {
117
+			throw new \LogicException("No policies.");
118
+		}
119
+		$elements = array_map(
120
+			function (PolicyInformation $pi) {
121
+				return $pi->toASN1();
122
+			}, array_values($this->_policies));
123
+		return new Sequence(...$elements);
124
+	}
125 125
     
126
-    /**
127
-     * Get the number of policies.
128
-     *
129
-     * @see \Countable::count()
130
-     * @return int
131
-     */
132
-    public function count()
133
-    {
134
-        return count($this->_policies);
135
-    }
126
+	/**
127
+	 * Get the number of policies.
128
+	 *
129
+	 * @see \Countable::count()
130
+	 * @return int
131
+	 */
132
+	public function count()
133
+	{
134
+		return count($this->_policies);
135
+	}
136 136
     
137
-    /**
138
-     * Get iterator for policy information terms.
139
-     *
140
-     * @see \IteratorAggregate::getIterator()
141
-     * @return \ArrayIterator
142
-     */
143
-    public function getIterator()
144
-    {
145
-        return new \ArrayIterator($this->_policies);
146
-    }
137
+	/**
138
+	 * Get iterator for policy information terms.
139
+	 *
140
+	 * @see \IteratorAggregate::getIterator()
141
+	 * @return \ArrayIterator
142
+	 */
143
+	public function getIterator()
144
+	{
145
+		return new \ArrayIterator($this->_policies);
146
+	}
147 147
 }
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/SubjectAlternativeNameExtension.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -12,53 +12,53 @@
 block discarded – undo
12 12
  */
13 13
 class SubjectAlternativeNameExtension extends Extension
14 14
 {
15
-    /**
16
-     * Names.
17
-     *
18
-     * @var GeneralNames $_names
19
-     */
20
-    protected $_names;
15
+	/**
16
+	 * Names.
17
+	 *
18
+	 * @var GeneralNames $_names
19
+	 */
20
+	protected $_names;
21 21
     
22
-    /**
23
-     * Constructor.
24
-     *
25
-     * @param bool $critical
26
-     * @param GeneralNames $names
27
-     */
28
-    public function __construct($critical, GeneralNames $names)
29
-    {
30
-        parent::__construct(self::OID_SUBJECT_ALT_NAME, $critical);
31
-        $this->_names = $names;
32
-    }
22
+	/**
23
+	 * Constructor.
24
+	 *
25
+	 * @param bool $critical
26
+	 * @param GeneralNames $names
27
+	 */
28
+	public function __construct($critical, GeneralNames $names)
29
+	{
30
+		parent::__construct(self::OID_SUBJECT_ALT_NAME, $critical);
31
+		$this->_names = $names;
32
+	}
33 33
     
34
-    /**
35
-     *
36
-     * {@inheritdoc}
37
-     * @return self
38
-     */
39
-    protected static function _fromDER($data, $critical)
40
-    {
41
-        return new self($critical,
42
-            GeneralNames::fromASN1(Sequence::fromDER($data)));
43
-    }
34
+	/**
35
+	 *
36
+	 * {@inheritdoc}
37
+	 * @return self
38
+	 */
39
+	protected static function _fromDER($data, $critical)
40
+	{
41
+		return new self($critical,
42
+			GeneralNames::fromASN1(Sequence::fromDER($data)));
43
+	}
44 44
     
45
-    /**
46
-     * Get names.
47
-     *
48
-     * @return GeneralNames
49
-     */
50
-    public function names()
51
-    {
52
-        return $this->_names;
53
-    }
45
+	/**
46
+	 * Get names.
47
+	 *
48
+	 * @return GeneralNames
49
+	 */
50
+	public function names()
51
+	{
52
+		return $this->_names;
53
+	}
54 54
     
55
-    /**
56
-     *
57
-     * {@inheritdoc}
58
-     * @return Sequence
59
-     */
60
-    protected function _valueASN1()
61
-    {
62
-        return $this->_names->toASN1();
63
-    }
55
+	/**
56
+	 *
57
+	 * {@inheritdoc}
58
+	 * @return Sequence
59
+	 */
60
+	protected function _valueASN1()
61
+	{
62
+		return $this->_names->toASN1();
63
+	}
64 64
 }
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/IssuerAlternativeNameExtension.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -12,53 +12,53 @@
 block discarded – undo
12 12
  */
13 13
 class IssuerAlternativeNameExtension extends Extension
14 14
 {
15
-    /**
16
-     * Names.
17
-     *
18
-     * @var GeneralNames
19
-     */
20
-    protected $_names;
15
+	/**
16
+	 * Names.
17
+	 *
18
+	 * @var GeneralNames
19
+	 */
20
+	protected $_names;
21 21
     
22
-    /**
23
-     * Constructor.
24
-     *
25
-     * @param bool $critical
26
-     * @param GeneralNames $names
27
-     */
28
-    public function __construct($critical, GeneralNames $names)
29
-    {
30
-        parent::__construct(self::OID_ISSUER_ALT_NAME, $critical);
31
-        $this->_names = $names;
32
-    }
22
+	/**
23
+	 * Constructor.
24
+	 *
25
+	 * @param bool $critical
26
+	 * @param GeneralNames $names
27
+	 */
28
+	public function __construct($critical, GeneralNames $names)
29
+	{
30
+		parent::__construct(self::OID_ISSUER_ALT_NAME, $critical);
31
+		$this->_names = $names;
32
+	}
33 33
     
34
-    /**
35
-     *
36
-     * {@inheritdoc}
37
-     * @return self
38
-     */
39
-    protected static function _fromDER($data, $critical)
40
-    {
41
-        return new self($critical,
42
-            GeneralNames::fromASN1(Sequence::fromDER($data)));
43
-    }
34
+	/**
35
+	 *
36
+	 * {@inheritdoc}
37
+	 * @return self
38
+	 */
39
+	protected static function _fromDER($data, $critical)
40
+	{
41
+		return new self($critical,
42
+			GeneralNames::fromASN1(Sequence::fromDER($data)));
43
+	}
44 44
     
45
-    /**
46
-     * Get names.
47
-     *
48
-     * @return GeneralNames
49
-     */
50
-    public function names()
51
-    {
52
-        return $this->_names;
53
-    }
45
+	/**
46
+	 * Get names.
47
+	 *
48
+	 * @return GeneralNames
49
+	 */
50
+	public function names()
51
+	{
52
+		return $this->_names;
53
+	}
54 54
     
55
-    /**
56
-     *
57
-     * {@inheritdoc}
58
-     * @return Sequence
59
-     */
60
-    protected function _valueASN1()
61
-    {
62
-        return $this->_names->toASN1();
63
-    }
55
+	/**
56
+	 *
57
+	 * {@inheritdoc}
58
+	 * @return Sequence
59
+	 */
60
+	protected function _valueASN1()
61
+	{
62
+		return $this->_names->toASN1();
63
+	}
64 64
 }
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/CertificatePolicy/NoticeReference.php 1 patch
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -14,83 +14,83 @@
 block discarded – undo
14 14
  */
15 15
 class NoticeReference
16 16
 {
17
-    /**
18
-     * Organization.
19
-     *
20
-     * @var DisplayText $_organization
21
-     */
22
-    protected $_organization;
17
+	/**
18
+	 * Organization.
19
+	 *
20
+	 * @var DisplayText $_organization
21
+	 */
22
+	protected $_organization;
23 23
     
24
-    /**
25
-     * Notification reference numbers.
26
-     *
27
-     * @var int[] $_numbers
28
-     */
29
-    protected $_numbers;
24
+	/**
25
+	 * Notification reference numbers.
26
+	 *
27
+	 * @var int[] $_numbers
28
+	 */
29
+	protected $_numbers;
30 30
     
31
-    /**
32
-     * Constructor.
33
-     *
34
-     * @param DisplayText $organization
35
-     * @param int ...$numbers
36
-     */
37
-    public function __construct(DisplayText $organization, ...$numbers)
38
-    {
39
-        $this->_organization = $organization;
40
-        $this->_numbers = $numbers;
41
-    }
31
+	/**
32
+	 * Constructor.
33
+	 *
34
+	 * @param DisplayText $organization
35
+	 * @param int ...$numbers
36
+	 */
37
+	public function __construct(DisplayText $organization, ...$numbers)
38
+	{
39
+		$this->_organization = $organization;
40
+		$this->_numbers = $numbers;
41
+	}
42 42
     
43
-    /**
44
-     * Initialize from ASN.1.
45
-     *
46
-     * @param Sequence $seq
47
-     * @return self
48
-     */
49
-    public static function fromASN1(Sequence $seq)
50
-    {
51
-        $org = DisplayText::fromASN1($seq->at(0)->asString());
52
-        $numbers = array_map(
53
-            function (UnspecifiedType $el) {
54
-                return $el->asInteger()->number();
55
-            },
56
-            $seq->at(1)
57
-                ->asSequence()
58
-                ->elements());
59
-        return new self($org, ...$numbers);
60
-    }
43
+	/**
44
+	 * Initialize from ASN.1.
45
+	 *
46
+	 * @param Sequence $seq
47
+	 * @return self
48
+	 */
49
+	public static function fromASN1(Sequence $seq)
50
+	{
51
+		$org = DisplayText::fromASN1($seq->at(0)->asString());
52
+		$numbers = array_map(
53
+			function (UnspecifiedType $el) {
54
+				return $el->asInteger()->number();
55
+			},
56
+			$seq->at(1)
57
+				->asSequence()
58
+				->elements());
59
+		return new self($org, ...$numbers);
60
+	}
61 61
     
62
-    /**
63
-     * Get reference organization.
64
-     *
65
-     * @return DisplayText
66
-     */
67
-    public function organization()
68
-    {
69
-        return $this->_organization;
70
-    }
62
+	/**
63
+	 * Get reference organization.
64
+	 *
65
+	 * @return DisplayText
66
+	 */
67
+	public function organization()
68
+	{
69
+		return $this->_organization;
70
+	}
71 71
     
72
-    /**
73
-     * Get reference numbers.
74
-     *
75
-     * @return int[]
76
-     */
77
-    public function numbers()
78
-    {
79
-        return $this->_numbers;
80
-    }
72
+	/**
73
+	 * Get reference numbers.
74
+	 *
75
+	 * @return int[]
76
+	 */
77
+	public function numbers()
78
+	{
79
+		return $this->_numbers;
80
+	}
81 81
     
82
-    /**
83
-     * Generate ASN.1 structure.
84
-     *
85
-     * @return Sequence
86
-     */
87
-    public function toASN1()
88
-    {
89
-        $org = $this->_organization->toASN1();
90
-        $nums = array_map(
91
-            function ($number) {
92
-                return new Integer($number);
93
-            }, $this->_numbers);
94
-        return new Sequence($org, new Sequence(...$nums));
95
-    }
82
+	/**
83
+	 * Generate ASN.1 structure.
84
+	 *
85
+	 * @return Sequence
86
+	 */
87
+	public function toASN1()
88
+	{
89
+		$org = $this->_organization->toASN1();
90
+		$nums = array_map(
91
+			function ($number) {
92
+				return new Integer($number);
93
+			}, $this->_numbers);
94
+		return new Sequence($org, new Sequence(...$nums));
95
+	}
96 96
 }
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/CertificatePolicy/CPSQualifier.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -13,51 +13,51 @@
 block discarded – undo
13 13
  */
14 14
 class CPSQualifier extends PolicyQualifierInfo
15 15
 {
16
-    /**
17
-     * URI.
18
-     *
19
-     * @var string $_uri
20
-     */
21
-    protected $_uri;
16
+	/**
17
+	 * URI.
18
+	 *
19
+	 * @var string $_uri
20
+	 */
21
+	protected $_uri;
22 22
     
23
-    /**
24
-     * Constructor.
25
-     *
26
-     * @param string $uri
27
-     */
28
-    public function __construct($uri)
29
-    {
30
-        $this->_oid = self::OID_CPS;
31
-        $this->_uri = $uri;
32
-    }
23
+	/**
24
+	 * Constructor.
25
+	 *
26
+	 * @param string $uri
27
+	 */
28
+	public function __construct($uri)
29
+	{
30
+		$this->_oid = self::OID_CPS;
31
+		$this->_uri = $uri;
32
+	}
33 33
     
34
-    /**
35
-     *
36
-     * @param UnspecifiedType $el
37
-     * @return self
38
-     */
39
-    public static function fromQualifierASN1(UnspecifiedType $el)
40
-    {
41
-        return new self($el->asString()->string());
42
-    }
34
+	/**
35
+	 *
36
+	 * @param UnspecifiedType $el
37
+	 * @return self
38
+	 */
39
+	public static function fromQualifierASN1(UnspecifiedType $el)
40
+	{
41
+		return new self($el->asString()->string());
42
+	}
43 43
     
44
-    /**
45
-     * Get URI.
46
-     *
47
-     * @return string
48
-     */
49
-    public function uri()
50
-    {
51
-        return $this->_uri;
52
-    }
44
+	/**
45
+	 * Get URI.
46
+	 *
47
+	 * @return string
48
+	 */
49
+	public function uri()
50
+	{
51
+		return $this->_uri;
52
+	}
53 53
     
54
-    /**
55
-     *
56
-     * {@inheritdoc}
57
-     * @return IA5String
58
-     */
59
-    protected function _qualifierASN1()
60
-    {
61
-        return new IA5String($this->_uri);
62
-    }
54
+	/**
55
+	 *
56
+	 * {@inheritdoc}
57
+	 * @return IA5String
58
+	 */
59
+	protected function _qualifierASN1()
60
+	{
61
+		return new IA5String($this->_uri);
62
+	}
63 63
 }
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/CertificatePolicy/UserNoticeQualifier.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -14,114 +14,114 @@
 block discarded – undo
14 14
  */
15 15
 class UserNoticeQualifier extends PolicyQualifierInfo
16 16
 {
17
-    /**
18
-     * Explicit notice text.
19
-     *
20
-     * @var DisplayText $_text
21
-     */
22
-    protected $_text;
17
+	/**
18
+	 * Explicit notice text.
19
+	 *
20
+	 * @var DisplayText $_text
21
+	 */
22
+	protected $_text;
23 23
     
24
-    /**
25
-     * Notice reference.
26
-     *
27
-     * @var NoticeReference $_ref
28
-     */
29
-    protected $_ref;
24
+	/**
25
+	 * Notice reference.
26
+	 *
27
+	 * @var NoticeReference $_ref
28
+	 */
29
+	protected $_ref;
30 30
     
31
-    /**
32
-     * Constructor.
33
-     *
34
-     * @param DisplayText|null $text
35
-     * @param NoticeReference|null $ref
36
-     */
37
-    public function __construct(DisplayText $text = null, NoticeReference $ref = null)
38
-    {
39
-        $this->_oid = self::OID_UNOTICE;
40
-        $this->_text = $text;
41
-        $this->_ref = $ref;
42
-    }
31
+	/**
32
+	 * Constructor.
33
+	 *
34
+	 * @param DisplayText|null $text
35
+	 * @param NoticeReference|null $ref
36
+	 */
37
+	public function __construct(DisplayText $text = null, NoticeReference $ref = null)
38
+	{
39
+		$this->_oid = self::OID_UNOTICE;
40
+		$this->_text = $text;
41
+		$this->_ref = $ref;
42
+	}
43 43
     
44
-    /**
45
-     *
46
-     * @param UnspecifiedType $el
47
-     * @return self
48
-     */
49
-    public static function fromQualifierASN1(UnspecifiedType $el)
50
-    {
51
-        $seq = $el->asSequence();
52
-        $ref = null;
53
-        $text = null;
54
-        $idx = 0;
55
-        if ($seq->has($idx, Element::TYPE_SEQUENCE)) {
56
-            $ref = NoticeReference::fromASN1($seq->at($idx++)->asSequence());
57
-        }
58
-        if ($seq->has($idx, Element::TYPE_STRING)) {
59
-            $text = DisplayText::fromASN1($seq->at($idx)->asString());
60
-        }
61
-        return new self($text, $ref);
62
-    }
44
+	/**
45
+	 *
46
+	 * @param UnspecifiedType $el
47
+	 * @return self
48
+	 */
49
+	public static function fromQualifierASN1(UnspecifiedType $el)
50
+	{
51
+		$seq = $el->asSequence();
52
+		$ref = null;
53
+		$text = null;
54
+		$idx = 0;
55
+		if ($seq->has($idx, Element::TYPE_SEQUENCE)) {
56
+			$ref = NoticeReference::fromASN1($seq->at($idx++)->asSequence());
57
+		}
58
+		if ($seq->has($idx, Element::TYPE_STRING)) {
59
+			$text = DisplayText::fromASN1($seq->at($idx)->asString());
60
+		}
61
+		return new self($text, $ref);
62
+	}
63 63
     
64
-    /**
65
-     * Whether explicit text is present.
66
-     *
67
-     * @return bool
68
-     */
69
-    public function hasExplicitText()
70
-    {
71
-        return isset($this->_text);
72
-    }
64
+	/**
65
+	 * Whether explicit text is present.
66
+	 *
67
+	 * @return bool
68
+	 */
69
+	public function hasExplicitText()
70
+	{
71
+		return isset($this->_text);
72
+	}
73 73
     
74
-    /**
75
-     * Get explicit text.
76
-     *
77
-     * @return DisplayText
78
-     */
79
-    public function explicitText()
80
-    {
81
-        if (!$this->hasExplicitText()) {
82
-            throw new \LogicException("explicitText not set.");
83
-        }
84
-        return $this->_text;
85
-    }
74
+	/**
75
+	 * Get explicit text.
76
+	 *
77
+	 * @return DisplayText
78
+	 */
79
+	public function explicitText()
80
+	{
81
+		if (!$this->hasExplicitText()) {
82
+			throw new \LogicException("explicitText not set.");
83
+		}
84
+		return $this->_text;
85
+	}
86 86
     
87
-    /**
88
-     * Whether notice reference is present.
89
-     *
90
-     * @return bool
91
-     */
92
-    public function hasNoticeRef()
93
-    {
94
-        return isset($this->_ref);
95
-    }
87
+	/**
88
+	 * Whether notice reference is present.
89
+	 *
90
+	 * @return bool
91
+	 */
92
+	public function hasNoticeRef()
93
+	{
94
+		return isset($this->_ref);
95
+	}
96 96
     
97
-    /**
98
-     * Get notice reference.
99
-     *
100
-     * @throws \RuntimeException
101
-     * @return NoticeReference
102
-     */
103
-    public function noticeRef()
104
-    {
105
-        if (!$this->hasNoticeRef()) {
106
-            throw new \LogicException("noticeRef not set.");
107
-        }
108
-        return $this->_ref;
109
-    }
97
+	/**
98
+	 * Get notice reference.
99
+	 *
100
+	 * @throws \RuntimeException
101
+	 * @return NoticeReference
102
+	 */
103
+	public function noticeRef()
104
+	{
105
+		if (!$this->hasNoticeRef()) {
106
+			throw new \LogicException("noticeRef not set.");
107
+		}
108
+		return $this->_ref;
109
+	}
110 110
     
111
-    /**
112
-     *
113
-     * {@inheritdoc}
114
-     * @return Sequence
115
-     */
116
-    protected function _qualifierASN1()
117
-    {
118
-        $elements = array();
119
-        if (isset($this->_ref)) {
120
-            $elements[] = $this->_ref->toASN1();
121
-        }
122
-        if (isset($this->_text)) {
123
-            $elements[] = $this->_text->toASN1();
124
-        }
125
-        return new Sequence(...$elements);
126
-    }
111
+	/**
112
+	 *
113
+	 * {@inheritdoc}
114
+	 * @return Sequence
115
+	 */
116
+	protected function _qualifierASN1()
117
+	{
118
+		$elements = array();
119
+		if (isset($this->_ref)) {
120
+			$elements[] = $this->_ref->toASN1();
121
+		}
122
+		if (isset($this->_text)) {
123
+			$elements[] = $this->_text->toASN1();
124
+		}
125
+		return new Sequence(...$elements);
126
+	}
127 127
 }
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/CertificatePolicy/DisplayText.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -17,93 +17,93 @@
 block discarded – undo
17 17
  */
18 18
 class DisplayText
19 19
 {
20
-    /**
21
-     * Text.
22
-     *
23
-     * @var string $_text
24
-     */
25
-    protected $_text;
20
+	/**
21
+	 * Text.
22
+	 *
23
+	 * @var string $_text
24
+	 */
25
+	protected $_text;
26 26
     
27
-    /**
28
-     * Element tag.
29
-     *
30
-     * @var int $_tag
31
-     */
32
-    protected $_tag;
27
+	/**
28
+	 * Element tag.
29
+	 *
30
+	 * @var int $_tag
31
+	 */
32
+	protected $_tag;
33 33
     
34
-    /**
35
-     * Constructor.
36
-     *
37
-     * @param string $text
38
-     * @param int $tag
39
-     */
40
-    public function __construct($text, $tag)
41
-    {
42
-        $this->_text = $text;
43
-        $this->_tag = $tag;
44
-    }
34
+	/**
35
+	 * Constructor.
36
+	 *
37
+	 * @param string $text
38
+	 * @param int $tag
39
+	 */
40
+	public function __construct($text, $tag)
41
+	{
42
+		$this->_text = $text;
43
+		$this->_tag = $tag;
44
+	}
45 45
     
46
-    /**
47
-     * Initialize from ASN.1.
48
-     *
49
-     * @param StringType $el
50
-     * @return self
51
-     */
52
-    public static function fromASN1(StringType $el)
53
-    {
54
-        return new self($el->string(), $el->tag());
55
-    }
46
+	/**
47
+	 * Initialize from ASN.1.
48
+	 *
49
+	 * @param StringType $el
50
+	 * @return self
51
+	 */
52
+	public static function fromASN1(StringType $el)
53
+	{
54
+		return new self($el->string(), $el->tag());
55
+	}
56 56
     
57
-    /**
58
-     * Initialize from a UTF-8 string.
59
-     *
60
-     * @param string $str
61
-     * @return self
62
-     */
63
-    public static function fromString($str)
64
-    {
65
-        return new self($str, Element::TYPE_UTF8_STRING);
66
-    }
57
+	/**
58
+	 * Initialize from a UTF-8 string.
59
+	 *
60
+	 * @param string $str
61
+	 * @return self
62
+	 */
63
+	public static function fromString($str)
64
+	{
65
+		return new self($str, Element::TYPE_UTF8_STRING);
66
+	}
67 67
     
68
-    /**
69
-     * Get the text.
70
-     *
71
-     * @return string
72
-     */
73
-    public function string()
74
-    {
75
-        return $this->_text;
76
-    }
68
+	/**
69
+	 * Get the text.
70
+	 *
71
+	 * @return string
72
+	 */
73
+	public function string()
74
+	{
75
+		return $this->_text;
76
+	}
77 77
     
78
-    /**
79
-     * Generate ASN.1 element.
80
-     *
81
-     * @throws \UnexpectedValueException
82
-     * @return StringType
83
-     */
84
-    public function toASN1()
85
-    {
86
-        switch ($this->_tag) {
87
-            case Element::TYPE_IA5_STRING:
88
-                return new IA5String($this->_text);
89
-            case Element::TYPE_VISIBLE_STRING:
90
-                return new VisibleString($this->_text);
91
-            case Element::TYPE_BMP_STRING:
92
-                return new BMPString($this->_text);
93
-            case Element::TYPE_UTF8_STRING:
94
-                return new UTF8String($this->_text);
95
-            default:
96
-                throw new \UnexpectedValueException(
97
-                    "Type " . Element::tagToName($this->_tag) . " not supported.");
98
-        }
99
-    }
78
+	/**
79
+	 * Generate ASN.1 element.
80
+	 *
81
+	 * @throws \UnexpectedValueException
82
+	 * @return StringType
83
+	 */
84
+	public function toASN1()
85
+	{
86
+		switch ($this->_tag) {
87
+			case Element::TYPE_IA5_STRING:
88
+				return new IA5String($this->_text);
89
+			case Element::TYPE_VISIBLE_STRING:
90
+				return new VisibleString($this->_text);
91
+			case Element::TYPE_BMP_STRING:
92
+				return new BMPString($this->_text);
93
+			case Element::TYPE_UTF8_STRING:
94
+				return new UTF8String($this->_text);
95
+			default:
96
+				throw new \UnexpectedValueException(
97
+					"Type " . Element::tagToName($this->_tag) . " not supported.");
98
+		}
99
+	}
100 100
     
101
-    /**
102
-     *
103
-     * @return string
104
-     */
105
-    public function __toString()
106
-    {
107
-        return $this->string();
108
-    }
101
+	/**
102
+	 *
103
+	 * @return string
104
+	 */
105
+	public function __toString()
106
+	{
107
+		return $this->string();
108
+	}
109 109
 }
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/CertificatePolicy/PolicyInformation.php 1 patch
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -14,207 +14,207 @@
 block discarded – undo
14 14
  */
15 15
 class PolicyInformation implements \Countable, \IteratorAggregate
16 16
 {
17
-    /**
18
-     * Wildcard policy.
19
-     *
20
-     * @var string
21
-     */
22
-    const OID_ANY_POLICY = "2.5.29.32.0";
23
-    
24
-    /**
25
-     * Policy identifier.
26
-     *
27
-     * @var string $_oid
28
-     */
29
-    protected $_oid;
30
-    
31
-    /**
32
-     * Policy qualifiers.
33
-     *
34
-     * @var PolicyQualifierInfo[] $_qualifiers
35
-     */
36
-    protected $_qualifiers;
37
-    
38
-    /**
39
-     * Constructor.
40
-     *
41
-     * @param string $oid
42
-     * @param PolicyQualifierInfo ...$qualifiers
43
-     */
44
-    public function __construct($oid, PolicyQualifierInfo ...$qualifiers)
45
-    {
46
-        $this->_oid = $oid;
47
-        $this->_qualifiers = array();
48
-        foreach ($qualifiers as $qual) {
49
-            $this->_qualifiers[$qual->oid()] = $qual;
50
-        }
51
-    }
52
-    
53
-    /**
54
-     * Initialize from ASN.1.
55
-     *
56
-     * @param Sequence $seq
57
-     * @return self
58
-     */
59
-    public static function fromASN1(Sequence $seq)
60
-    {
61
-        $oid = $seq->at(0)
62
-            ->asObjectIdentifier()
63
-            ->oid();
64
-        $qualifiers = array();
65
-        if (count($seq) > 1) {
66
-            $qualifiers = array_map(
67
-                function (UnspecifiedType $el) {
68
-                    return PolicyQualifierInfo::fromASN1($el->asSequence());
69
-                },
70
-                $seq->at(1)
71
-                    ->asSequence()
72
-                    ->elements());
73
-        }
74
-        return new self($oid, ...$qualifiers);
75
-    }
76
-    
77
-    /**
78
-     * Get policy identifier.
79
-     *
80
-     * @return string
81
-     */
82
-    public function oid()
83
-    {
84
-        return $this->_oid;
85
-    }
86
-    
87
-    /**
88
-     * Check whether this policy is anyPolicy.
89
-     *
90
-     * @return bool
91
-     */
92
-    public function isAnyPolicy()
93
-    {
94
-        return self::OID_ANY_POLICY == $this->_oid;
95
-    }
96
-    
97
-    /**
98
-     * Get policy qualifiers.
99
-     *
100
-     * @return PolicyQualifierInfo[]
101
-     */
102
-    public function qualifiers()
103
-    {
104
-        return array_values($this->_qualifiers);
105
-    }
106
-    
107
-    /**
108
-     * Check whether qualifier is present.
109
-     *
110
-     * @param string $oid
111
-     * @return boolean
112
-     */
113
-    public function has($oid)
114
-    {
115
-        return isset($this->_qualifiers[$oid]);
116
-    }
117
-    
118
-    /**
119
-     * Get qualifier by OID.
120
-     *
121
-     * @param string $oid
122
-     * @throws \OutOfBoundsException
123
-     * @return PolicyQualifierInfo
124
-     */
125
-    public function get($oid)
126
-    {
127
-        if (!$this->has($oid)) {
128
-            throw new \LogicException("No $oid qualifier.");
129
-        }
130
-        return $this->_qualifiers[$oid];
131
-    }
132
-    
133
-    /**
134
-     * Check whether CPS qualifier is present.
135
-     *
136
-     * @return bool
137
-     */
138
-    public function hasCPSQualifier()
139
-    {
140
-        return $this->has(PolicyQualifierInfo::OID_CPS);
141
-    }
142
-    
143
-    /**
144
-     * Get CPS qualifier.
145
-     *
146
-     * @throws \LogicException
147
-     * @return CPSQualifier
148
-     */
149
-    public function CPSQualifier()
150
-    {
151
-        if (!$this->hasCPSQualifier()) {
152
-            throw new \LogicException("CPS qualifier not set.");
153
-        }
154
-        return $this->get(PolicyQualifierInfo::OID_CPS);
155
-    }
156
-    
157
-    /**
158
-     * Check whether user notice qualifier is present.
159
-     *
160
-     * @return bool
161
-     */
162
-    public function hasUserNoticeQualifier()
163
-    {
164
-        return $this->has(PolicyQualifierInfo::OID_UNOTICE);
165
-    }
166
-    
167
-    /**
168
-     * Get user notice qualifier.
169
-     *
170
-     * @throws \LogicException
171
-     * @return UserNoticeQualifier
172
-     */
173
-    public function userNoticeQualifier()
174
-    {
175
-        if (!$this->hasUserNoticeQualifier()) {
176
-            throw new \LogicException("User notice qualifier not set.");
177
-        }
178
-        return $this->get(PolicyQualifierInfo::OID_UNOTICE);
179
-    }
180
-    
181
-    /**
182
-     * Get ASN.1 structure.
183
-     *
184
-     * @return Sequence
185
-     */
186
-    public function toASN1()
187
-    {
188
-        $elements = array(new ObjectIdentifier($this->_oid));
189
-        if (count($this->_qualifiers)) {
190
-            $qualifiers = array_map(
191
-                function (PolicyQualifierInfo $pqi) {
192
-                    return $pqi->toASN1();
193
-                }, array_values($this->_qualifiers));
194
-            $elements[] = new Sequence(...$qualifiers);
195
-        }
196
-        return new Sequence(...$elements);
197
-    }
198
-    
199
-    /**
200
-     * Get number of qualifiers.
201
-     *
202
-     * @see \Countable::count()
203
-     * @return int
204
-     */
205
-    public function count()
206
-    {
207
-        return count($this->_qualifiers);
208
-    }
209
-    
210
-    /**
211
-     * Get iterator for qualifiers.
212
-     *
213
-     * @see \IteratorAggregate::getIterator()
214
-     * @return \ArrayIterator
215
-     */
216
-    public function getIterator()
217
-    {
218
-        return new \ArrayIterator($this->_qualifiers);
219
-    }
17
+	/**
18
+	 * Wildcard policy.
19
+	 *
20
+	 * @var string
21
+	 */
22
+	const OID_ANY_POLICY = "2.5.29.32.0";
23
+    
24
+	/**
25
+	 * Policy identifier.
26
+	 *
27
+	 * @var string $_oid
28
+	 */
29
+	protected $_oid;
30
+    
31
+	/**
32
+	 * Policy qualifiers.
33
+	 *
34
+	 * @var PolicyQualifierInfo[] $_qualifiers
35
+	 */
36
+	protected $_qualifiers;
37
+    
38
+	/**
39
+	 * Constructor.
40
+	 *
41
+	 * @param string $oid
42
+	 * @param PolicyQualifierInfo ...$qualifiers
43
+	 */
44
+	public function __construct($oid, PolicyQualifierInfo ...$qualifiers)
45
+	{
46
+		$this->_oid = $oid;
47
+		$this->_qualifiers = array();
48
+		foreach ($qualifiers as $qual) {
49
+			$this->_qualifiers[$qual->oid()] = $qual;
50
+		}
51
+	}
52
+    
53
+	/**
54
+	 * Initialize from ASN.1.
55
+	 *
56
+	 * @param Sequence $seq
57
+	 * @return self
58
+	 */
59
+	public static function fromASN1(Sequence $seq)
60
+	{
61
+		$oid = $seq->at(0)
62
+			->asObjectIdentifier()
63
+			->oid();
64
+		$qualifiers = array();
65
+		if (count($seq) > 1) {
66
+			$qualifiers = array_map(
67
+				function (UnspecifiedType $el) {
68
+					return PolicyQualifierInfo::fromASN1($el->asSequence());
69
+				},
70
+				$seq->at(1)
71
+					->asSequence()
72
+					->elements());
73
+		}
74
+		return new self($oid, ...$qualifiers);
75
+	}
76
+    
77
+	/**
78
+	 * Get policy identifier.
79
+	 *
80
+	 * @return string
81
+	 */
82
+	public function oid()
83
+	{
84
+		return $this->_oid;
85
+	}
86
+    
87
+	/**
88
+	 * Check whether this policy is anyPolicy.
89
+	 *
90
+	 * @return bool
91
+	 */
92
+	public function isAnyPolicy()
93
+	{
94
+		return self::OID_ANY_POLICY == $this->_oid;
95
+	}
96
+    
97
+	/**
98
+	 * Get policy qualifiers.
99
+	 *
100
+	 * @return PolicyQualifierInfo[]
101
+	 */
102
+	public function qualifiers()
103
+	{
104
+		return array_values($this->_qualifiers);
105
+	}
106
+    
107
+	/**
108
+	 * Check whether qualifier is present.
109
+	 *
110
+	 * @param string $oid
111
+	 * @return boolean
112
+	 */
113
+	public function has($oid)
114
+	{
115
+		return isset($this->_qualifiers[$oid]);
116
+	}
117
+    
118
+	/**
119
+	 * Get qualifier by OID.
120
+	 *
121
+	 * @param string $oid
122
+	 * @throws \OutOfBoundsException
123
+	 * @return PolicyQualifierInfo
124
+	 */
125
+	public function get($oid)
126
+	{
127
+		if (!$this->has($oid)) {
128
+			throw new \LogicException("No $oid qualifier.");
129
+		}
130
+		return $this->_qualifiers[$oid];
131
+	}
132
+    
133
+	/**
134
+	 * Check whether CPS qualifier is present.
135
+	 *
136
+	 * @return bool
137
+	 */
138
+	public function hasCPSQualifier()
139
+	{
140
+		return $this->has(PolicyQualifierInfo::OID_CPS);
141
+	}
142
+    
143
+	/**
144
+	 * Get CPS qualifier.
145
+	 *
146
+	 * @throws \LogicException
147
+	 * @return CPSQualifier
148
+	 */
149
+	public function CPSQualifier()
150
+	{
151
+		if (!$this->hasCPSQualifier()) {
152
+			throw new \LogicException("CPS qualifier not set.");
153
+		}
154
+		return $this->get(PolicyQualifierInfo::OID_CPS);
155
+	}
156
+    
157
+	/**
158
+	 * Check whether user notice qualifier is present.
159
+	 *
160
+	 * @return bool
161
+	 */
162
+	public function hasUserNoticeQualifier()
163
+	{
164
+		return $this->has(PolicyQualifierInfo::OID_UNOTICE);
165
+	}
166
+    
167
+	/**
168
+	 * Get user notice qualifier.
169
+	 *
170
+	 * @throws \LogicException
171
+	 * @return UserNoticeQualifier
172
+	 */
173
+	public function userNoticeQualifier()
174
+	{
175
+		if (!$this->hasUserNoticeQualifier()) {
176
+			throw new \LogicException("User notice qualifier not set.");
177
+		}
178
+		return $this->get(PolicyQualifierInfo::OID_UNOTICE);
179
+	}
180
+    
181
+	/**
182
+	 * Get ASN.1 structure.
183
+	 *
184
+	 * @return Sequence
185
+	 */
186
+	public function toASN1()
187
+	{
188
+		$elements = array(new ObjectIdentifier($this->_oid));
189
+		if (count($this->_qualifiers)) {
190
+			$qualifiers = array_map(
191
+				function (PolicyQualifierInfo $pqi) {
192
+					return $pqi->toASN1();
193
+				}, array_values($this->_qualifiers));
194
+			$elements[] = new Sequence(...$qualifiers);
195
+		}
196
+		return new Sequence(...$elements);
197
+	}
198
+    
199
+	/**
200
+	 * Get number of qualifiers.
201
+	 *
202
+	 * @see \Countable::count()
203
+	 * @return int
204
+	 */
205
+	public function count()
206
+	{
207
+		return count($this->_qualifiers);
208
+	}
209
+    
210
+	/**
211
+	 * Get iterator for qualifiers.
212
+	 *
213
+	 * @see \IteratorAggregate::getIterator()
214
+	 * @return \ArrayIterator
215
+	 */
216
+	public function getIterator()
217
+	{
218
+		return new \ArrayIterator($this->_qualifiers);
219
+	}
220 220
 }
Please login to merge, or discard this patch.