Browse code

added appinfo/info.xml appinfo/signature.json CHANGELOG.txt lib/AppInfo/Application.php css/style.css providers/Plivo

DoubleBastionAdmin authored on 05/11/2025 13:35:09
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,55 @@
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
+}