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 ( 59f4b4...e271c1 )
by Joni
03:51
created
lib/JWX/Parameter/Feature/StringParameterValue.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -11,22 +11,22 @@
 block discarded – undo
11 11
  */
12 12
 trait StringParameterValue
13 13
 {
14
-    /**
15
-     * Constructor.
16
-     *
17
-     * @param string $value Parameter value
18
-     */
19
-    abstract public function __construct(string $value);
14
+	/**
15
+	 * Constructor.
16
+	 *
17
+	 * @param string $value Parameter value
18
+	 */
19
+	abstract public function __construct(string $value);
20 20
 
21
-    /**
22
-     * Initialize from a JSON value.
23
-     *
24
-     * @param string $value
25
-     *
26
-     * @return static
27
-     */
28
-    public static function fromJSONValue($value): Parameter
29
-    {
30
-        return new static(strval($value));
31
-    }
21
+	/**
22
+	 * Initialize from a JSON value.
23
+	 *
24
+	 * @param string $value
25
+	 *
26
+	 * @return static
27
+	 */
28
+	public static function fromJSONValue($value): Parameter
29
+	{
30
+		return new static(strval($value));
31
+	}
32 32
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\JWX\Parameter\Feature;
6 6
 
Please login to merge, or discard this patch.
lib/JWX/Parameter/Parameter.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -9,37 +9,37 @@
 block discarded – undo
9 9
  */
10 10
 abstract class Parameter
11 11
 {
12
-    /**
13
-     * Parameter name.
14
-     *
15
-     * @var string
16
-     */
17
-    protected $_name;
12
+	/**
13
+	 * Parameter name.
14
+	 *
15
+	 * @var string
16
+	 */
17
+	protected $_name;
18 18
 
19
-    /**
20
-     * Parameter value.
21
-     *
22
-     * @var mixed
23
-     */
24
-    protected $_value;
19
+	/**
20
+	 * Parameter value.
21
+	 *
22
+	 * @var mixed
23
+	 */
24
+	protected $_value;
25 25
 
26
-    /**
27
-     * Get the parameter name.
28
-     *
29
-     * @return string
30
-     */
31
-    public function name(): string
32
-    {
33
-        return $this->_name;
34
-    }
26
+	/**
27
+	 * Get the parameter name.
28
+	 *
29
+	 * @return string
30
+	 */
31
+	public function name(): string
32
+	{
33
+		return $this->_name;
34
+	}
35 35
 
36
-    /**
37
-     * Get the parameter value.
38
-     *
39
-     * @return mixed
40
-     */
41
-    public function value()
42
-    {
43
-        return $this->_value;
44
-    }
36
+	/**
37
+	 * Get the parameter value.
38
+	 *
39
+	 * @return mixed
40
+	 */
41
+	public function value()
42
+	{
43
+		return $this->_value;
44
+	}
45 45
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\JWX\Parameter;
6 6
 
Please login to merge, or discard this patch.
lib/JWX/JWK/Symmetric/SymmetricKeyJWK.php 2 patches
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -17,61 +17,61 @@
 block discarded – undo
17 17
  */
18 18
 class SymmetricKeyJWK extends JWK
19 19
 {
20
-    /**
21
-     * Parameter names managed by this class.
22
-     *
23
-     * @internal
24
-     *
25
-     * @var string[]
26
-     */
27
-    const MANAGED_PARAMS = [
28
-        JWKParameter::PARAM_KEY_TYPE,
29
-        JWKParameter::PARAM_KEY_VALUE,
30
-    ];
20
+	/**
21
+	 * Parameter names managed by this class.
22
+	 *
23
+	 * @internal
24
+	 *
25
+	 * @var string[]
26
+	 */
27
+	const MANAGED_PARAMS = [
28
+		JWKParameter::PARAM_KEY_TYPE,
29
+		JWKParameter::PARAM_KEY_VALUE,
30
+	];
31 31
 
32
-    /**
33
-     * Constructor.
34
-     *
35
-     * @param JWKParameter ...$params
36
-     *
37
-     * @throws \UnexpectedValueException If missing required parameter
38
-     */
39
-    public function __construct(JWKParameter ...$params)
40
-    {
41
-        parent::__construct(...$params);
42
-        foreach (self::MANAGED_PARAMS as $name) {
43
-            if (!$this->has($name)) {
44
-                throw new \UnexpectedValueException(
45
-                    "Missing '{$name}' parameter.");
46
-            }
47
-        }
48
-        if (KeyTypeParameter::TYPE_OCT !== $this->keyTypeParameter()->value()) {
49
-            throw new \UnexpectedValueException('Invalid key type.');
50
-        }
51
-    }
32
+	/**
33
+	 * Constructor.
34
+	 *
35
+	 * @param JWKParameter ...$params
36
+	 *
37
+	 * @throws \UnexpectedValueException If missing required parameter
38
+	 */
39
+	public function __construct(JWKParameter ...$params)
40
+	{
41
+		parent::__construct(...$params);
42
+		foreach (self::MANAGED_PARAMS as $name) {
43
+			if (!$this->has($name)) {
44
+				throw new \UnexpectedValueException(
45
+					"Missing '{$name}' parameter.");
46
+			}
47
+		}
48
+		if (KeyTypeParameter::TYPE_OCT !== $this->keyTypeParameter()->value()) {
49
+			throw new \UnexpectedValueException('Invalid key type.');
50
+		}
51
+	}
52 52
 
53
-    /**
54
-     * Initialize from a key string.
55
-     *
56
-     * @param string       $key       Symmetric key
57
-     * @param JWKParameter ...$params Optional additional parameters
58
-     *
59
-     * @return self
60
-     */
61
-    public static function fromKey(string $key, JWKParameter ...$params): self
62
-    {
63
-        $params[] = new KeyTypeParameter(KeyTypeParameter::TYPE_OCT);
64
-        $params[] = KeyValueParameter::fromString($key);
65
-        return new self(...$params);
66
-    }
53
+	/**
54
+	 * Initialize from a key string.
55
+	 *
56
+	 * @param string       $key       Symmetric key
57
+	 * @param JWKParameter ...$params Optional additional parameters
58
+	 *
59
+	 * @return self
60
+	 */
61
+	public static function fromKey(string $key, JWKParameter ...$params): self
62
+	{
63
+		$params[] = new KeyTypeParameter(KeyTypeParameter::TYPE_OCT);
64
+		$params[] = KeyValueParameter::fromString($key);
65
+		return new self(...$params);
66
+	}
67 67
 
68
-    /**
69
-     * Get the symmetric key.
70
-     *
71
-     * @return string
72
-     */
73
-    public function key(): string
74
-    {
75
-        return Base64::urlDecode($this->keyValueParameter()->value());
76
-    }
68
+	/**
69
+	 * Get the symmetric key.
70
+	 *
71
+	 * @return string
72
+	 */
73
+	public function key(): string
74
+	{
75
+		return Base64::urlDecode($this->keyValueParameter()->value());
76
+	}
77 77
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\JWX\JWK\Symmetric;
6 6
 
Please login to merge, or discard this patch.
lib/JWX/JWK/JWKSet.php 2 patches
Indentation   +235 added lines, -235 removed lines patch added patch discarded remove patch
@@ -13,239 +13,239 @@
 block discarded – undo
13 13
  */
14 14
 class JWKSet implements \Countable, \IteratorAggregate
15 15
 {
16
-    /**
17
-     * JWK objects.
18
-     *
19
-     * @var JWK[]
20
-     */
21
-    protected $_jwks;
22
-
23
-    /**
24
-     * Additional members.
25
-     *
26
-     * @var array
27
-     */
28
-    protected $_additional;
29
-
30
-    /**
31
-     * JWK mappings.
32
-     *
33
-     * @var array
34
-     */
35
-    private $_mappings = [];
36
-
37
-    /**
38
-     * Constructor.
39
-     *
40
-     * @param JWK ...$jwks
41
-     */
42
-    public function __construct(JWK ...$jwks)
43
-    {
44
-        $this->_jwks = $jwks;
45
-        $this->_additional = [];
46
-    }
47
-
48
-    /**
49
-     * Reset internal cache variables on clone.
50
-     */
51
-    public function __clone()
52
-    {
53
-        $this->_mappings = [];
54
-    }
55
-
56
-    /**
57
-     * Initialize from an array representing a JSON object.
58
-     *
59
-     * @param array $members
60
-     *
61
-     * @throws \UnexpectedValueException
62
-     *
63
-     * @return self
64
-     */
65
-    public static function fromArray(array $members): self
66
-    {
67
-        if (!isset($members['keys']) || !is_array($members['keys'])) {
68
-            throw new \UnexpectedValueException(
69
-                "JWK Set must have a 'keys' member.");
70
-        }
71
-        $jwks = array_map(
72
-            function ($jwkdata) {
73
-                return JWK::fromArray($jwkdata);
74
-            }, $members['keys']);
75
-        unset($members['keys']);
76
-        $obj = new self(...$jwks);
77
-        $obj->_additional = $members;
78
-        return $obj;
79
-    }
80
-
81
-    /**
82
-     * Initialize from a JSON string.
83
-     *
84
-     * @param string $json
85
-     *
86
-     * @throws \UnexpectedValueException
87
-     *
88
-     * @return self
89
-     */
90
-    public static function fromJSON(string $json): self
91
-    {
92
-        $members = json_decode($json, true, 32, JSON_BIGINT_AS_STRING);
93
-        if (!is_array($members)) {
94
-            throw new \UnexpectedValueException('Invalid JSON.');
95
-        }
96
-        return self::fromArray($members);
97
-    }
98
-
99
-    /**
100
-     * Get self with keys added.
101
-     *
102
-     * @param JWK ...$keys JWK objects
103
-     *
104
-     * @return self
105
-     */
106
-    public function withKeys(JWK ...$keys): self
107
-    {
108
-        $obj = clone $this;
109
-        $obj->_jwks = array_merge($obj->_jwks, $keys);
110
-        return $obj;
111
-    }
112
-
113
-    /**
114
-     * Get all JWK's in a set.
115
-     *
116
-     * @return JWK[]
117
-     */
118
-    public function keys(): array
119
-    {
120
-        return $this->_jwks;
121
-    }
122
-
123
-    /**
124
-     * Get the first JWK in the set.
125
-     *
126
-     * @throws \LogicException
127
-     *
128
-     * @return JWK
129
-     */
130
-    public function first(): JWK
131
-    {
132
-        if (!count($this->_jwks)) {
133
-            throw new \LogicException('No keys.');
134
-        }
135
-        return $this->_jwks[0];
136
-    }
137
-
138
-    /**
139
-     * Check whether set has a JWK with a given key ID.
140
-     *
141
-     * @param string $id
142
-     *
143
-     * @return bool
144
-     */
145
-    public function hasKeyID(string $id): bool
146
-    {
147
-        return null !== $this->_getKeyByID($id);
148
-    }
149
-
150
-    /**
151
-     * Get a JWK by a key ID.
152
-     *
153
-     * @param string $id
154
-     *
155
-     * @throws \LogicException
156
-     *
157
-     * @return JWK
158
-     */
159
-    public function keyByID(string $id): JWK
160
-    {
161
-        $jwk = $this->_getKeyByID($id);
162
-        if (!$jwk) {
163
-            throw new \LogicException("No key ID {$id}.");
164
-        }
165
-        return $jwk;
166
-    }
167
-
168
-    /**
169
-     * Convert to array.
170
-     *
171
-     * @return array
172
-     */
173
-    public function toArray(): array
174
-    {
175
-        $data = $this->_additional;
176
-        $data['keys'] = array_map(
177
-            function (JWK $jwk) {
178
-                return $jwk->toArray();
179
-            }, $this->_jwks);
180
-        return $data;
181
-    }
182
-
183
-    /**
184
-     * Convert to JSON.
185
-     *
186
-     * @return string
187
-     */
188
-    public function toJSON(): string
189
-    {
190
-        return json_encode((object) $this->toArray(), JSON_UNESCAPED_SLASHES);
191
-    }
192
-
193
-    /**
194
-     * Get the number of keys.
195
-     *
196
-     * @see \Countable::count()
197
-     */
198
-    public function count(): int
199
-    {
200
-        return count($this->_jwks);
201
-    }
202
-
203
-    /**
204
-     * Get iterator for JWK objects.
205
-     *
206
-     * @see \IteratorAggregate::getIterator()
207
-     *
208
-     * @return \ArrayIterator
209
-     */
210
-    public function getIterator(): \ArrayIterator
211
-    {
212
-        return new \ArrayIterator($this->_jwks);
213
-    }
214
-
215
-    /**
216
-     * Get JWK by key ID.
217
-     *
218
-     * @param string $id
219
-     *
220
-     * @return null|JWK Null if not found
221
-     */
222
-    protected function _getKeyByID(string $id): ?JWK
223
-    {
224
-        $map = $this->_getMapping(JWKParameter::PARAM_KEY_ID);
225
-        return isset($map[$id]) ? $map[$id] : null;
226
-    }
227
-
228
-    /**
229
-     * Get mapping from parameter values of given parameter name to JWK.
230
-     *
231
-     * Later duplicate value shall override earlier JWK.
232
-     *
233
-     * @param string $name Parameter name
234
-     *
235
-     * @return array
236
-     */
237
-    protected function _getMapping(string $name): array
238
-    {
239
-        if (!isset($this->_mappings[$name])) {
240
-            $mapping = [];
241
-            foreach ($this->_jwks as $jwk) {
242
-                if ($jwk->has($name)) {
243
-                    $key = (string) $jwk->get($name)->value();
244
-                    $mapping[$key] = $jwk;
245
-                }
246
-            }
247
-            $this->_mappings[$name] = $mapping;
248
-        }
249
-        return $this->_mappings[$name];
250
-    }
16
+	/**
17
+	 * JWK objects.
18
+	 *
19
+	 * @var JWK[]
20
+	 */
21
+	protected $_jwks;
22
+
23
+	/**
24
+	 * Additional members.
25
+	 *
26
+	 * @var array
27
+	 */
28
+	protected $_additional;
29
+
30
+	/**
31
+	 * JWK mappings.
32
+	 *
33
+	 * @var array
34
+	 */
35
+	private $_mappings = [];
36
+
37
+	/**
38
+	 * Constructor.
39
+	 *
40
+	 * @param JWK ...$jwks
41
+	 */
42
+	public function __construct(JWK ...$jwks)
43
+	{
44
+		$this->_jwks = $jwks;
45
+		$this->_additional = [];
46
+	}
47
+
48
+	/**
49
+	 * Reset internal cache variables on clone.
50
+	 */
51
+	public function __clone()
52
+	{
53
+		$this->_mappings = [];
54
+	}
55
+
56
+	/**
57
+	 * Initialize from an array representing a JSON object.
58
+	 *
59
+	 * @param array $members
60
+	 *
61
+	 * @throws \UnexpectedValueException
62
+	 *
63
+	 * @return self
64
+	 */
65
+	public static function fromArray(array $members): self
66
+	{
67
+		if (!isset($members['keys']) || !is_array($members['keys'])) {
68
+			throw new \UnexpectedValueException(
69
+				"JWK Set must have a 'keys' member.");
70
+		}
71
+		$jwks = array_map(
72
+			function ($jwkdata) {
73
+				return JWK::fromArray($jwkdata);
74
+			}, $members['keys']);
75
+		unset($members['keys']);
76
+		$obj = new self(...$jwks);
77
+		$obj->_additional = $members;
78
+		return $obj;
79
+	}
80
+
81
+	/**
82
+	 * Initialize from a JSON string.
83
+	 *
84
+	 * @param string $json
85
+	 *
86
+	 * @throws \UnexpectedValueException
87
+	 *
88
+	 * @return self
89
+	 */
90
+	public static function fromJSON(string $json): self
91
+	{
92
+		$members = json_decode($json, true, 32, JSON_BIGINT_AS_STRING);
93
+		if (!is_array($members)) {
94
+			throw new \UnexpectedValueException('Invalid JSON.');
95
+		}
96
+		return self::fromArray($members);
97
+	}
98
+
99
+	/**
100
+	 * Get self with keys added.
101
+	 *
102
+	 * @param JWK ...$keys JWK objects
103
+	 *
104
+	 * @return self
105
+	 */
106
+	public function withKeys(JWK ...$keys): self
107
+	{
108
+		$obj = clone $this;
109
+		$obj->_jwks = array_merge($obj->_jwks, $keys);
110
+		return $obj;
111
+	}
112
+
113
+	/**
114
+	 * Get all JWK's in a set.
115
+	 *
116
+	 * @return JWK[]
117
+	 */
118
+	public function keys(): array
119
+	{
120
+		return $this->_jwks;
121
+	}
122
+
123
+	/**
124
+	 * Get the first JWK in the set.
125
+	 *
126
+	 * @throws \LogicException
127
+	 *
128
+	 * @return JWK
129
+	 */
130
+	public function first(): JWK
131
+	{
132
+		if (!count($this->_jwks)) {
133
+			throw new \LogicException('No keys.');
134
+		}
135
+		return $this->_jwks[0];
136
+	}
137
+
138
+	/**
139
+	 * Check whether set has a JWK with a given key ID.
140
+	 *
141
+	 * @param string $id
142
+	 *
143
+	 * @return bool
144
+	 */
145
+	public function hasKeyID(string $id): bool
146
+	{
147
+		return null !== $this->_getKeyByID($id);
148
+	}
149
+
150
+	/**
151
+	 * Get a JWK by a key ID.
152
+	 *
153
+	 * @param string $id
154
+	 *
155
+	 * @throws \LogicException
156
+	 *
157
+	 * @return JWK
158
+	 */
159
+	public function keyByID(string $id): JWK
160
+	{
161
+		$jwk = $this->_getKeyByID($id);
162
+		if (!$jwk) {
163
+			throw new \LogicException("No key ID {$id}.");
164
+		}
165
+		return $jwk;
166
+	}
167
+
168
+	/**
169
+	 * Convert to array.
170
+	 *
171
+	 * @return array
172
+	 */
173
+	public function toArray(): array
174
+	{
175
+		$data = $this->_additional;
176
+		$data['keys'] = array_map(
177
+			function (JWK $jwk) {
178
+				return $jwk->toArray();
179
+			}, $this->_jwks);
180
+		return $data;
181
+	}
182
+
183
+	/**
184
+	 * Convert to JSON.
185
+	 *
186
+	 * @return string
187
+	 */
188
+	public function toJSON(): string
189
+	{
190
+		return json_encode((object) $this->toArray(), JSON_UNESCAPED_SLASHES);
191
+	}
192
+
193
+	/**
194
+	 * Get the number of keys.
195
+	 *
196
+	 * @see \Countable::count()
197
+	 */
198
+	public function count(): int
199
+	{
200
+		return count($this->_jwks);
201
+	}
202
+
203
+	/**
204
+	 * Get iterator for JWK objects.
205
+	 *
206
+	 * @see \IteratorAggregate::getIterator()
207
+	 *
208
+	 * @return \ArrayIterator
209
+	 */
210
+	public function getIterator(): \ArrayIterator
211
+	{
212
+		return new \ArrayIterator($this->_jwks);
213
+	}
214
+
215
+	/**
216
+	 * Get JWK by key ID.
217
+	 *
218
+	 * @param string $id
219
+	 *
220
+	 * @return null|JWK Null if not found
221
+	 */
222
+	protected function _getKeyByID(string $id): ?JWK
223
+	{
224
+		$map = $this->_getMapping(JWKParameter::PARAM_KEY_ID);
225
+		return isset($map[$id]) ? $map[$id] : null;
226
+	}
227
+
228
+	/**
229
+	 * Get mapping from parameter values of given parameter name to JWK.
230
+	 *
231
+	 * Later duplicate value shall override earlier JWK.
232
+	 *
233
+	 * @param string $name Parameter name
234
+	 *
235
+	 * @return array
236
+	 */
237
+	protected function _getMapping(string $name): array
238
+	{
239
+		if (!isset($this->_mappings[$name])) {
240
+			$mapping = [];
241
+			foreach ($this->_jwks as $jwk) {
242
+				if ($jwk->has($name)) {
243
+					$key = (string) $jwk->get($name)->value();
244
+					$mapping[$key] = $jwk;
245
+				}
246
+			}
247
+			$this->_mappings[$name] = $mapping;
248
+		}
249
+		return $this->_mappings[$name];
250
+	}
251 251
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\JWX\JWK;
6 6
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
                 "JWK Set must have a 'keys' member.");
70 70
         }
71 71
         $jwks = array_map(
72
-            function ($jwkdata) {
72
+            function($jwkdata) {
73 73
                 return JWK::fromArray($jwkdata);
74 74
             }, $members['keys']);
75 75
         unset($members['keys']);
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
     {
175 175
         $data = $this->_additional;
176 176
         $data['keys'] = array_map(
177
-            function (JWK $jwk) {
177
+            function(JWK $jwk) {
178 178
                 return $jwk->toArray();
179 179
             }, $this->_jwks);
180 180
         return $data;
Please login to merge, or discard this patch.
lib/JWX/JWK/RSA/RSAPublicKeyJWK.php 2 patches
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -22,77 +22,77 @@
 block discarded – undo
22 22
  */
23 23
 class RSAPublicKeyJWK extends PublicKeyJWK
24 24
 {
25
-    /**
26
-     * Parameter names managed by this class.
27
-     *
28
-     * @internal
29
-     *
30
-     * @var string[]
31
-     */
32
-    const MANAGED_PARAMS = [
33
-        JWKParameter::PARAM_KEY_TYPE,
34
-        JWKParameter::PARAM_MODULUS,
35
-        JWKParameter::PARAM_EXPONENT,
36
-    ];
25
+	/**
26
+	 * Parameter names managed by this class.
27
+	 *
28
+	 * @internal
29
+	 *
30
+	 * @var string[]
31
+	 */
32
+	const MANAGED_PARAMS = [
33
+		JWKParameter::PARAM_KEY_TYPE,
34
+		JWKParameter::PARAM_MODULUS,
35
+		JWKParameter::PARAM_EXPONENT,
36
+	];
37 37
 
38
-    /**
39
-     * Constructor.
40
-     *
41
-     * @param JWKParameter ...$params
42
-     *
43
-     * @throws \UnexpectedValueException If missing required parameter
44
-     */
45
-    public function __construct(JWKParameter ...$params)
46
-    {
47
-        parent::__construct(...$params);
48
-        foreach (self::MANAGED_PARAMS as $name) {
49
-            if (!$this->has($name)) {
50
-                throw new \UnexpectedValueException(
51
-                    "Missing '{$name}' parameter.");
52
-            }
53
-        }
54
-        if (KeyTypeParameter::TYPE_RSA !== $this->keyTypeParameter()->value()) {
55
-            throw new \UnexpectedValueException('Invalid key type.');
56
-        }
57
-    }
38
+	/**
39
+	 * Constructor.
40
+	 *
41
+	 * @param JWKParameter ...$params
42
+	 *
43
+	 * @throws \UnexpectedValueException If missing required parameter
44
+	 */
45
+	public function __construct(JWKParameter ...$params)
46
+	{
47
+		parent::__construct(...$params);
48
+		foreach (self::MANAGED_PARAMS as $name) {
49
+			if (!$this->has($name)) {
50
+				throw new \UnexpectedValueException(
51
+					"Missing '{$name}' parameter.");
52
+			}
53
+		}
54
+		if (KeyTypeParameter::TYPE_RSA !== $this->keyTypeParameter()->value()) {
55
+			throw new \UnexpectedValueException('Invalid key type.');
56
+		}
57
+	}
58 58
 
59
-    /**
60
-     * Initialize from RSAPublicKey.
61
-     *
62
-     * @param RSAPublicKey $pk
63
-     *
64
-     * @return self
65
-     */
66
-    public static function fromRSAPublicKey(RSAPublicKey $pk): self
67
-    {
68
-        $n = ModulusParameter::fromNumber($pk->modulus());
69
-        $e = ExponentParameter::fromNumber($pk->publicExponent());
70
-        $key_type = new KeyTypeParameter(KeyTypeParameter::TYPE_RSA);
71
-        return new self($key_type, $n, $e);
72
-    }
59
+	/**
60
+	 * Initialize from RSAPublicKey.
61
+	 *
62
+	 * @param RSAPublicKey $pk
63
+	 *
64
+	 * @return self
65
+	 */
66
+	public static function fromRSAPublicKey(RSAPublicKey $pk): self
67
+	{
68
+		$n = ModulusParameter::fromNumber($pk->modulus());
69
+		$e = ExponentParameter::fromNumber($pk->publicExponent());
70
+		$key_type = new KeyTypeParameter(KeyTypeParameter::TYPE_RSA);
71
+		return new self($key_type, $n, $e);
72
+	}
73 73
 
74
-    /**
75
-     * Initialize from PEM.
76
-     *
77
-     * @param PEM $pem
78
-     *
79
-     * @return self
80
-     */
81
-    public static function fromPEM(PEM $pem): self
82
-    {
83
-        return self::fromRSAPublicKey(RSAPublicKey::fromPEM($pem));
84
-    }
74
+	/**
75
+	 * Initialize from PEM.
76
+	 *
77
+	 * @param PEM $pem
78
+	 *
79
+	 * @return self
80
+	 */
81
+	public static function fromPEM(PEM $pem): self
82
+	{
83
+		return self::fromRSAPublicKey(RSAPublicKey::fromPEM($pem));
84
+	}
85 85
 
86
-    /**
87
-     * Convert JWK to PEM.
88
-     *
89
-     * @return PEM
90
-     */
91
-    public function toPEM(): PEM
92
-    {
93
-        $n = $this->modulusParameter()->number()->base10();
94
-        $e = $this->exponentParameter()->number()->base10();
95
-        $pk = new RSAPublicKey($n, $e);
96
-        return PublicKeyInfo::fromPublicKey($pk)->toPEM();
97
-    }
86
+	/**
87
+	 * Convert JWK to PEM.
88
+	 *
89
+	 * @return PEM
90
+	 */
91
+	public function toPEM(): PEM
92
+	{
93
+		$n = $this->modulusParameter()->number()->base10();
94
+		$e = $this->exponentParameter()->number()->base10();
95
+		$pk = new RSAPublicKey($n, $e);
96
+		return PublicKeyInfo::fromPublicKey($pk)->toPEM();
97
+	}
98 98
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\JWX\JWK\RSA;
6 6
 
Please login to merge, or discard this patch.
lib/JWX/JWK/RSA/RSAPrivateKeyJWK.php 2 patches
Indentation   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -29,112 +29,112 @@
 block discarded – undo
29 29
  */
30 30
 class RSAPrivateKeyJWK extends PrivateKeyJWK
31 31
 {
32
-    /**
33
-     * Parameter names managed by this class.
34
-     *
35
-     * @internal
36
-     *
37
-     * @var string[]
38
-     */
39
-    const MANAGED_PARAMS = [
40
-        JWKParameter::PARAM_KEY_TYPE,
41
-        JWKParameter::PARAM_MODULUS,
42
-        JWKParameter::PARAM_EXPONENT,
43
-        JWKParameter::PARAM_PRIVATE_EXPONENT,
44
-        JWKParameter::PARAM_FIRST_PRIME_FACTOR,
45
-        JWKParameter::PARAM_SECOND_PRIME_FACTOR,
46
-        JWKParameter::PARAM_FIRST_FACTOR_CRT_EXPONENT,
47
-        JWKParameter::PARAM_SECOND_FACTOR_CRT_EXPONENT,
48
-        JWKParameter::PARAM_FIRST_CRT_COEFFICIENT,
49
-    ];
32
+	/**
33
+	 * Parameter names managed by this class.
34
+	 *
35
+	 * @internal
36
+	 *
37
+	 * @var string[]
38
+	 */
39
+	const MANAGED_PARAMS = [
40
+		JWKParameter::PARAM_KEY_TYPE,
41
+		JWKParameter::PARAM_MODULUS,
42
+		JWKParameter::PARAM_EXPONENT,
43
+		JWKParameter::PARAM_PRIVATE_EXPONENT,
44
+		JWKParameter::PARAM_FIRST_PRIME_FACTOR,
45
+		JWKParameter::PARAM_SECOND_PRIME_FACTOR,
46
+		JWKParameter::PARAM_FIRST_FACTOR_CRT_EXPONENT,
47
+		JWKParameter::PARAM_SECOND_FACTOR_CRT_EXPONENT,
48
+		JWKParameter::PARAM_FIRST_CRT_COEFFICIENT,
49
+	];
50 50
 
51
-    /**
52
-     * Constructor.
53
-     *
54
-     * @param JWKParameter ...$params
55
-     *
56
-     * @throws \UnexpectedValueException If missing required parameter
57
-     */
58
-    public function __construct(JWKParameter ...$params)
59
-    {
60
-        parent::__construct(...$params);
61
-        foreach (self::MANAGED_PARAMS as $name) {
62
-            if (!$this->has($name)) {
63
-                throw new \UnexpectedValueException(
64
-                    "Missing '{$name}' parameter.");
65
-            }
66
-        }
67
-        if (KeyTypeParameter::TYPE_RSA !== $this->keyTypeParameter()->value()) {
68
-            throw new \UnexpectedValueException('Invalid key type.');
69
-        }
70
-        // cast private exponent to correct class
71
-        $key = JWKParameter::PARAM_PRIVATE_EXPONENT;
72
-        $this->_parameters[$key] = new PrivateExponentParameter(
73
-            $this->_parameters[$key]->value());
74
-    }
51
+	/**
52
+	 * Constructor.
53
+	 *
54
+	 * @param JWKParameter ...$params
55
+	 *
56
+	 * @throws \UnexpectedValueException If missing required parameter
57
+	 */
58
+	public function __construct(JWKParameter ...$params)
59
+	{
60
+		parent::__construct(...$params);
61
+		foreach (self::MANAGED_PARAMS as $name) {
62
+			if (!$this->has($name)) {
63
+				throw new \UnexpectedValueException(
64
+					"Missing '{$name}' parameter.");
65
+			}
66
+		}
67
+		if (KeyTypeParameter::TYPE_RSA !== $this->keyTypeParameter()->value()) {
68
+			throw new \UnexpectedValueException('Invalid key type.');
69
+		}
70
+		// cast private exponent to correct class
71
+		$key = JWKParameter::PARAM_PRIVATE_EXPONENT;
72
+		$this->_parameters[$key] = new PrivateExponentParameter(
73
+			$this->_parameters[$key]->value());
74
+	}
75 75
 
76
-    /**
77
-     * Initialize from RSAPrivateKey.
78
-     *
79
-     * @param RSAPrivateKey $pk
80
-     *
81
-     * @return self
82
-     */
83
-    public static function fromRSAPrivateKey(RSAPrivateKey $pk): self
84
-    {
85
-        $n = ModulusParameter::fromNumber($pk->modulus());
86
-        $e = ExponentParameter::fromNumber($pk->publicExponent());
87
-        $d = PrivateExponentParameter::fromNumber($pk->privateExponent());
88
-        $p = FirstPrimeFactorParameter::fromNumber($pk->prime1());
89
-        $q = SecondPrimeFactorParameter::fromNumber($pk->prime2());
90
-        $dp = FirstFactorCRTExponentParameter::fromNumber($pk->exponent1());
91
-        $dq = SecondFactorCRTExponentParameter::fromNumber($pk->exponent2());
92
-        $qi = FirstCRTCoefficientParameter::fromNumber($pk->coefficient());
93
-        $key_type = new KeyTypeParameter(KeyTypeParameter::TYPE_RSA);
94
-        return new self($key_type, $n, $e, $d, $p, $q, $dp, $dq, $qi);
95
-    }
76
+	/**
77
+	 * Initialize from RSAPrivateKey.
78
+	 *
79
+	 * @param RSAPrivateKey $pk
80
+	 *
81
+	 * @return self
82
+	 */
83
+	public static function fromRSAPrivateKey(RSAPrivateKey $pk): self
84
+	{
85
+		$n = ModulusParameter::fromNumber($pk->modulus());
86
+		$e = ExponentParameter::fromNumber($pk->publicExponent());
87
+		$d = PrivateExponentParameter::fromNumber($pk->privateExponent());
88
+		$p = FirstPrimeFactorParameter::fromNumber($pk->prime1());
89
+		$q = SecondPrimeFactorParameter::fromNumber($pk->prime2());
90
+		$dp = FirstFactorCRTExponentParameter::fromNumber($pk->exponent1());
91
+		$dq = SecondFactorCRTExponentParameter::fromNumber($pk->exponent2());
92
+		$qi = FirstCRTCoefficientParameter::fromNumber($pk->coefficient());
93
+		$key_type = new KeyTypeParameter(KeyTypeParameter::TYPE_RSA);
94
+		return new self($key_type, $n, $e, $d, $p, $q, $dp, $dq, $qi);
95
+	}
96 96
 
97
-    /**
98
-     * Initialize from PEM.
99
-     *
100
-     * @param PEM $pem
101
-     *
102
-     * @return self
103
-     */
104
-    public static function fromPEM(PEM $pem): self
105
-    {
106
-        return self::fromRSAPrivateKey(RSAPrivateKey::fromPEM($pem));
107
-    }
97
+	/**
98
+	 * Initialize from PEM.
99
+	 *
100
+	 * @param PEM $pem
101
+	 *
102
+	 * @return self
103
+	 */
104
+	public static function fromPEM(PEM $pem): self
105
+	{
106
+		return self::fromRSAPrivateKey(RSAPrivateKey::fromPEM($pem));
107
+	}
108 108
 
109
-    /**
110
-     * Get public key component.
111
-     *
112
-     * @return RSAPublicKeyJWK
113
-     */
114
-    public function publicKey(): PublicKeyJWK
115
-    {
116
-        $kty = $this->keyTypeParameter();
117
-        $n = $this->modulusParameter();
118
-        $e = $this->exponentParameter();
119
-        return new RSAPublicKeyJWK($kty, $n, $e);
120
-    }
109
+	/**
110
+	 * Get public key component.
111
+	 *
112
+	 * @return RSAPublicKeyJWK
113
+	 */
114
+	public function publicKey(): PublicKeyJWK
115
+	{
116
+		$kty = $this->keyTypeParameter();
117
+		$n = $this->modulusParameter();
118
+		$e = $this->exponentParameter();
119
+		return new RSAPublicKeyJWK($kty, $n, $e);
120
+	}
121 121
 
122
-    /**
123
-     * Convert JWK to PEM.
124
-     *
125
-     * @return PEM
126
-     */
127
-    public function toPEM(): PEM
128
-    {
129
-        $n = $this->modulusParameter()->number()->base10();
130
-        $e = $this->exponentParameter()->number()->base10();
131
-        $d = $this->privateExponentParameter()->number()->base10();
132
-        $p = $this->firstPrimeFactorParameter()->number()->base10();
133
-        $q = $this->secondPrimeFactorParameter()->number()->base10();
134
-        $dp = $this->firstFactorCRTExponentParameter()->number()->base10();
135
-        $dq = $this->secondFactorCRTExponentParameter()->number()->base10();
136
-        $qi = $this->firstCRTCoefficientParameter()->number()->base10();
137
-        $pk = new RSAPrivateKey($n, $e, $d, $p, $q, $dp, $dq, $qi);
138
-        return PrivateKeyInfo::fromPrivateKey($pk)->toPEM();
139
-    }
122
+	/**
123
+	 * Convert JWK to PEM.
124
+	 *
125
+	 * @return PEM
126
+	 */
127
+	public function toPEM(): PEM
128
+	{
129
+		$n = $this->modulusParameter()->number()->base10();
130
+		$e = $this->exponentParameter()->number()->base10();
131
+		$d = $this->privateExponentParameter()->number()->base10();
132
+		$p = $this->firstPrimeFactorParameter()->number()->base10();
133
+		$q = $this->secondPrimeFactorParameter()->number()->base10();
134
+		$dp = $this->firstFactorCRTExponentParameter()->number()->base10();
135
+		$dq = $this->secondFactorCRTExponentParameter()->number()->base10();
136
+		$qi = $this->firstCRTCoefficientParameter()->number()->base10();
137
+		$pk = new RSAPrivateKey($n, $e, $d, $p, $q, $dp, $dq, $qi);
138
+		return PrivateKeyInfo::fromPrivateKey($pk)->toPEM();
139
+	}
140 140
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\JWX\JWK\RSA;
6 6
 
Please login to merge, or discard this patch.
lib/JWX/JWK/Parameter/PrivateExponentParameter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\JWX\JWK\Parameter;
6 6
 
Please login to merge, or discard this patch.
lib/JWX/JWK/Parameter/X509CertificateChainParameter.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -14,21 +14,21 @@
 block discarded – undo
14 14
  */
15 15
 class X509CertificateChainParameter extends JWKParameter
16 16
 {
17
-    use ArrayParameterValue;
17
+	use ArrayParameterValue;
18 18
 
19
-    /**
20
-     * Constructor.
21
-     *
22
-     * @param string ...$certs Base64 encoded DER certificates
23
-     */
24
-    public function __construct(string ...$certs)
25
-    {
26
-        foreach ($certs as $cert) {
27
-            if (!Base64::isValid($cert)) {
28
-                throw new \UnexpectedValueException(
29
-                    'Certificate must be base64 encoded.');
30
-            }
31
-        }
32
-        parent::__construct(self::PARAM_X509_CERTIFICATE_CHAIN, $certs);
33
-    }
19
+	/**
20
+	 * Constructor.
21
+	 *
22
+	 * @param string ...$certs Base64 encoded DER certificates
23
+	 */
24
+	public function __construct(string ...$certs)
25
+	{
26
+		foreach ($certs as $cert) {
27
+			if (!Base64::isValid($cert)) {
28
+				throw new \UnexpectedValueException(
29
+					'Certificate must be base64 encoded.');
30
+			}
31
+		}
32
+		parent::__construct(self::PARAM_X509_CERTIFICATE_CHAIN, $certs);
33
+	}
34 34
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\JWX\JWK\Parameter;
6 6
 
Please login to merge, or discard this patch.
lib/JWX/JWK/Parameter/KeyOperationsParameter.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -13,24 +13,24 @@
 block discarded – undo
13 13
  */
14 14
 class KeyOperationsParameter extends JWKParameter
15 15
 {
16
-    use ArrayParameterValue;
16
+	use ArrayParameterValue;
17 17
 
18
-    const OP_SIGN = 'sign';
19
-    const OP_VERIFY = 'verify';
20
-    const OP_ENCRYPT = 'encrypt';
21
-    const OP_DECRYPT = 'decrypt';
22
-    const OP_WRAP_KEY = 'wrapKey';
23
-    const OP_UNWRAP_KEY = 'unwrapKey';
24
-    const OP_DERIVE_KEY = 'deriveKey';
25
-    const OP_DERIVE_BITS = 'deriveBits';
18
+	const OP_SIGN = 'sign';
19
+	const OP_VERIFY = 'verify';
20
+	const OP_ENCRYPT = 'encrypt';
21
+	const OP_DECRYPT = 'decrypt';
22
+	const OP_WRAP_KEY = 'wrapKey';
23
+	const OP_UNWRAP_KEY = 'unwrapKey';
24
+	const OP_DERIVE_KEY = 'deriveKey';
25
+	const OP_DERIVE_BITS = 'deriveBits';
26 26
 
27
-    /**
28
-     * Constructor.
29
-     *
30
-     * @param string ...$ops Key operations
31
-     */
32
-    public function __construct(string ...$ops)
33
-    {
34
-        parent::__construct(self::PARAM_KEY_OPERATIONS, $ops);
35
-    }
27
+	/**
28
+	 * Constructor.
29
+	 *
30
+	 * @param string ...$ops Key operations
31
+	 */
32
+	public function __construct(string ...$ops)
33
+	{
34
+		parent::__construct(self::PARAM_KEY_OPERATIONS, $ops);
35
+	}
36 36
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\JWX\JWK\Parameter;
6 6
 
Please login to merge, or discard this patch.