Skip to content

Commit 83ff07e

Browse files
committed
support PHP 8.0
1 parent 02a481a commit 83ff07e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/Key.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Firebase\JWT;
44

55
use InvalidArgumentException;
6+
use OpenSSLAsymmetricKey;
67

78
class Key
89
{
@@ -18,9 +19,18 @@ class Key
1819
*/
1920
public function __construct($keyMaterial, $algorithm)
2021
{
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');
2328
}
29+
30+
if (empty($keyMaterial)) {
31+
throw new InvalidArgumentException('Type error: $keyMaterial must not be empty');
32+
}
33+
2434
if (!is_string($algorithm)|| empty($keyMaterial)) {
2535
throw new InvalidArgumentException('Type error: $algorithm must be a string');
2636
}

0 commit comments

Comments
 (0)