1 | <?php |
||
9 | class Payload implements \ArrayAccess |
||
10 | { |
||
11 | /** |
||
12 | * The array of claims |
||
13 | * |
||
14 | * @var \Tymon\JWTAuth\Claims\Claim[] |
||
15 | */ |
||
16 | private $claims = []; |
||
17 | |||
18 | /** |
||
19 | * Build the Payload |
||
20 | * |
||
21 | * @param array $claims |
||
22 | * @param \Tymon\JWTAuth\Validators\PayloadValidator $validator |
||
23 | * @param bool $refreshFlow |
||
24 | */ |
||
25 | 66 | public function __construct(array $claims, PayloadValidator $validator, $refreshFlow = false) |
|
31 | |||
32 | /** |
||
33 | * Get the array of claim instances |
||
34 | * |
||
35 | * @return \Tymon\JWTAuth\Claims\Claim[] |
||
36 | */ |
||
37 | 3 | public function getClaims() |
|
41 | |||
42 | /** |
||
43 | * Get the array of claims |
||
44 | * |
||
45 | * @return array |
||
46 | */ |
||
47 | 66 | public function toArray() |
|
56 | |||
57 | /** |
||
58 | * Get the payload |
||
59 | * |
||
60 | * @param string $claim |
||
61 | * @return mixed |
||
62 | */ |
||
63 | 24 | public function get($claim = null) |
|
75 | |||
76 | /** |
||
77 | * Determine whether the payload has the claim |
||
78 | * |
||
79 | * @param \Tymon\JWTAuth\Claims\Claim $claim |
||
80 | * @return boolean |
||
81 | */ |
||
82 | 3 | public function has(Claim $claim) |
|
86 | |||
87 | /** |
||
88 | * Get the payload as a string |
||
89 | * |
||
90 | * @return string |
||
91 | */ |
||
92 | 3 | public function __toString() |
|
96 | |||
97 | /** |
||
98 | * Determine if an item exists at an offset. |
||
99 | * |
||
100 | * @param mixed $key |
||
101 | * @return bool |
||
102 | */ |
||
103 | 3 | public function offsetExists($key) |
|
107 | |||
108 | /** |
||
109 | * Get an item at a given offset. |
||
110 | * |
||
111 | * @param mixed $key |
||
112 | * @return mixed |
||
113 | */ |
||
114 | 24 | public function offsetGet($key) |
|
118 | |||
119 | /** |
||
120 | * Don't allow changing the payload as it should be immutable |
||
121 | * |
||
122 | * @param mixed $key |
||
123 | * @param mixed $value |
||
124 | * @throws Exceptions\PayloadException |
||
125 | * @return void |
||
126 | */ |
||
127 | 3 | public function offsetSet($key, $value) |
|
131 | |||
132 | /** |
||
133 | * Don't allow changing the payload as it should be immutable |
||
134 | * |
||
135 | * @param string $key |
||
136 | * @throws Exceptions\PayloadException |
||
137 | * @return void |
||
138 | */ |
||
139 | 3 | public function offsetUnset($key) |
|
143 | |||
144 | /** |
||
145 | * Magically get a claim value |
||
146 | * |
||
147 | * @param string $method |
||
148 | * @param array $parameters |
||
149 | * @return mixed |
||
150 | * @throws \BadMethodCallException |
||
151 | */ |
||
152 | 6 | public function __call($method, $parameters) |
|
166 | } |
||
167 |