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