PluginProbe
WP-Stateless – Google Cloud Storage / trunk
WP-Stateless – Google Cloud Storage vtrunk
4.4.3 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.3.0 2.3.1 2.3.2 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 All 62 releases
wp-stateless / vendor / firebase / php-jwt / src / Key.php

Key.php in WP-Stateless – Google Cloud Storage trunk, at vendor/firebase/php-jwt/src/Key.php

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