File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 3
3
namespace Firebase \JWT ;
4
4
5
5
use InvalidArgumentException ;
6
+ use OpenSSLAsymmetricKey ;
6
7
7
8
class Key
8
9
{
@@ -18,9 +19,18 @@ class Key
18
19
*/
19
20
public function __construct ($ keyMaterial , $ algorithm )
20
21
{
21
- if (!(is_string ($ keyMaterial ) || is_resource ($ keyMaterial )) || empty ($ keyMaterial )) {
22
- throw new InvalidArgumentException ('Type error: $keyMaterial must be a string ' );
22
+ if (
23
+ !is_string ($ keyMaterial )
24
+ && !is_resource ($ keyMaterial )
25
+ && !$ keyMaterial instanceof OpenSSLAsymmetricKey
26
+ ) {
27
+ throw new InvalidArgumentException ('Type error: $keyMaterial must be a string, resource, or OpenSSLAsymmetricKey ' );
23
28
}
29
+
30
+ if (empty ($ keyMaterial )) {
31
+ throw new InvalidArgumentException ('Type error: $keyMaterial must not be empty ' );
32
+ }
33
+
24
34
if (!is_string ($ algorithm )|| empty ($ keyMaterial )) {
25
35
throw new InvalidArgumentException ('Type error: $algorithm must be a string ' );
26
36
}
You can’t perform that action at this time.
0 commit comments