PluginProbe
Media Cloud Sync / 1.2.6
Media Cloud Sync v1.2.6
1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 All 34 releases
media-cloud-sync / includes / sdk / google / firebase / php-jwt / src / Key.php

Key.php in Media Cloud Sync 1.2.6, at includes/sdk/google/firebase/php-jwt/src/Key.php

51 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Dudlewebs\WPMCS\Firebase\JWT;
4
5 use InvalidArgumentException;
6 use OpenSSLAsymmetricKey;
7 use OpenSSLCertificate;
8 use TypeError;
9 class Key
10 {
11 /** @var string|resource|OpenSSLAsymmetricKey|OpenSSLCertificate */
12 private $keyMaterial;
13 /** @var string */
14 private $algorithm;
15 /**
16 * @param string|resource|OpenSSLAsymmetricKey|OpenSSLCertificate $keyMaterial
17 * @param string $algorithm
18 */
19 public function __construct($keyMaterial, string $algorithm)
20 {
21 if (!\is_string($keyMaterial) && !$keyMaterial instanceof OpenSSLAsymmetricKey && !$keyMaterial instanceof OpenSSLCertificate && !\is_resource($keyMaterial)) {
22 throw new TypeError('Key material must be a string, resource, or OpenSSLAsymmetricKey');
23 }
24 if (empty($keyMaterial)) {
25 throw new InvalidArgumentException('Key material must not be empty');
26 }
27 if (empty($algorithm)) {
28 throw new InvalidArgumentException('Algorithm must not be empty');
29 }
30 // TODO: Remove in PHP 8.0 in favor of class constructor property promotion
31 $this->keyMaterial = $keyMaterial;
32 $this->algorithm = $algorithm;
33 }
34 /**
35 * Return the algorithm valid for this key
36 *
37 * @return string
38 */
39 public function getAlgorithm(): string
40 {
41 return $this->algorithm;
42 }
43 /**
44 * @return string|resource|OpenSSLAsymmetricKey|OpenSSLCertificate
45 */
46 public function getKeyMaterial()
47 {
48 return $this->keyMaterial;
49 }
50 }
51