1 | <?php |
||
19 | final class JWKSet implements JWKSetInterface |
||
20 | { |
||
21 | /** |
||
22 | * @var int |
||
23 | */ |
||
24 | private $position = 0; |
||
25 | |||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | protected $keys = []; |
||
30 | |||
31 | public function __construct(array $keys = []) |
||
32 | { |
||
33 | if (array_key_exists('keys', $keys)) { |
||
34 | foreach ($keys['keys'] as $value) { |
||
35 | $key = new JWK($value); |
||
36 | $this->keys[] = $key; |
||
37 | } |
||
38 | } |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * {@inheritdoc} |
||
43 | */ |
||
44 | public function getKey($index) |
||
45 | { |
||
46 | Assertion::keyExists($this->keys, $index, 'Undefined index.'); |
||
47 | |||
48 | return $this->keys[$index]; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * {@inheritdoc} |
||
53 | */ |
||
54 | public function getKeys() |
||
58 | |||
59 | /** |
||
60 | * {@inheritdoc} |
||
61 | */ |
||
62 | public function addKey(JWKInterface $key) |
||
69 | |||
70 | /** |
||
71 | * {@inheritdoc} |
||
72 | */ |
||
73 | public function removeKey($key) |
||
84 | |||
85 | /** |
||
86 | * {@inheritdoc} |
||
87 | */ |
||
88 | public function jsonSerialize() |
||
92 | |||
93 | /** |
||
94 | * {@inheritdoc} |
||
95 | */ |
||
96 | public function count($mode = COUNT_NORMAL) |
||
100 | |||
101 | /** |
||
102 | * {@inheritdoc} |
||
103 | */ |
||
104 | public function current() |
||
108 | |||
109 | /** |
||
110 | * {@inheritdoc} |
||
111 | */ |
||
112 | public function key() |
||
116 | |||
117 | /** |
||
118 | * {@inheritdoc} |
||
119 | */ |
||
120 | public function next() |
||
124 | |||
125 | /** |
||
126 | * {@inheritdoc} |
||
127 | */ |
||
128 | public function rewind() |
||
132 | |||
133 | /** |
||
134 | * {@inheritdoc} |
||
135 | */ |
||
136 | public function valid() |
||
140 | |||
141 | /** |
||
142 | * {@inheritdoc} |
||
143 | */ |
||
144 | public function countKeys() |
||
148 | } |
||
149 |