PluginProbe
Authorizer / 3.3.2
Authorizer v3.3.2
3.15.3 3.15.2 3.15.1 3.15.0 3.14.3 3.14.4 3.14.2 3.14.1 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.9.0 2.9.1 2.9.10 2.9.11 2.9.12 2.9.13 2.9.2 2.9.3 2.9.6 All 126 releases
authorizer / vendor / firebase / php-jwt / src / Key.php

Key.php in Authorizer 3.3.2, at vendor/firebase/php-jwt/src/Key.php

60 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Firebase\JWT;
4
5 use InvalidArgumentException;
6 use OpenSSLAsymmetricKey;
7
8 class Key
9 {
10 /** @var string $algorithm */
11 private $algorithm;
12
13 /** @var string|resource|OpenSSLAsymmetricKey $keyMaterial */
14 private $keyMaterial;
15
16 /**
17 * @param string|resource|OpenSSLAsymmetricKey $keyMaterial
18 * @param string $algorithm
19 */
20 public function __construct($keyMaterial, $algorithm)
21 {
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');
28 }
29
30 if (empty($keyMaterial)) {
31 throw new InvalidArgumentException('Type error: $keyMaterial must not be empty');
32 }
33
34 if (!is_string($algorithm)|| empty($keyMaterial)) {
35 throw new InvalidArgumentException('Type error: $algorithm must be a string');
36 }
37
38 $this->keyMaterial = $keyMaterial;
39 $this->algorithm = $algorithm;
40 }
41
42 /**
43 * Return the algorithm valid for this key
44 *
45 * @return string
46 */
47 public function getAlgorithm()
48 {
49 return $this->algorithm;
50 }
51
52 /**
53 * @return string|resource|OpenSSLAsymmetricKey
54 */
55 public function getKeyMaterial()
56 {
57 return $this->keyMaterial;
58 }
59 }
60