PluginProbe
Authorizer / 3.14.4
Authorizer v3.14.4
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.14.4, at vendor/firebase/php-jwt/src/Key.php

55 lines 1.3 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 use OpenSSLCertificate;
8 use TypeError;
9
10 class Key
11 {
12 /**
13 * @param string|OpenSSLAsymmetricKey|OpenSSLCertificate $keyMaterial
14 * @param string $algorithm
15 */
16 public function __construct(
17 #[\SensitiveParameter] private $keyMaterial,
18 private string $algorithm
19 ) {
20 if (
21 !\is_string($keyMaterial)
22 && !$keyMaterial instanceof OpenSSLAsymmetricKey
23 && !$keyMaterial instanceof OpenSSLCertificate
24 ) {
25 throw new TypeError('Key material must be a string, OpenSSLCertificate, or OpenSSLAsymmetricKey');
26 }
27
28 if (empty($keyMaterial)) {
29 throw new InvalidArgumentException('Key material must not be empty');
30 }
31
32 if (empty($algorithm)) {
33 throw new InvalidArgumentException('Algorithm must not be empty');
34 }
35 }
36
37 /**
38 * Return the algorithm valid for this key
39 *
40 * @return string
41 */
42 public function getAlgorithm(): string
43 {
44 return $this->algorithm;
45 }
46
47 /**
48 * @return string|OpenSSLAsymmetricKey|OpenSSLCertificate
49 */
50 public function getKeyMaterial()
51 {
52 return $this->keyMaterial;
53 }
54 }
55