1 | <?php |
||
21 | final class JWK implements \JsonSerializable |
||
22 | { |
||
23 | /** |
||
24 | * @var array |
||
25 | */ |
||
26 | private $values = []; |
||
27 | |||
28 | /** |
||
29 | * JWK constructor. |
||
30 | * |
||
31 | * @param array $values |
||
32 | */ |
||
33 | private function __construct(array $values) |
||
37 | |||
38 | /** |
||
39 | * @param array $values |
||
40 | * |
||
41 | * @return JWK |
||
42 | */ |
||
43 | public static function create(array $values): self |
||
51 | |||
52 | /** |
||
53 | * @param string $json |
||
54 | * |
||
55 | * @return JWK |
||
56 | */ |
||
57 | public static function createFromJson(string $json): self |
||
66 | |||
67 | /** |
||
68 | * {@inheritdoc} |
||
69 | */ |
||
70 | public function jsonSerialize() |
||
74 | |||
75 | /** |
||
76 | * Get the value with a specific key. |
||
77 | * |
||
78 | * @param string $key The key |
||
79 | * |
||
80 | * @throws \InvalidArgumentException |
||
81 | * |
||
82 | * @return mixed|null The value |
||
83 | */ |
||
84 | public function get(string $key) |
||
92 | |||
93 | /** |
||
94 | * Returns true if the JWK has the value identified by. |
||
95 | * |
||
96 | * @param string $key The key |
||
97 | * |
||
98 | * @return bool |
||
99 | */ |
||
100 | public function has(string $key): bool |
||
104 | |||
105 | /** |
||
106 | * Get all values stored in the JWK object. |
||
107 | * |
||
108 | * @return array Values of the JWK object |
||
109 | */ |
||
110 | public function all(): array |
||
114 | |||
115 | /** |
||
116 | * Returns the thumbprint of the key. |
||
117 | * |
||
118 | * @see https://tools.ietf.org/html/rfc7638 |
||
119 | * |
||
120 | * @param string $hash_algorithm |
||
121 | * |
||
122 | * @throws \InvalidArgumentException |
||
123 | * |
||
124 | * @return string |
||
125 | */ |
||
126 | public function thumbprint(string $hash_algorithm): string |
||
138 | |||
139 | /** |
||
140 | * @return JWK |
||
141 | */ |
||
142 | public function toPublic(): self |
||
148 | } |
||
149 |