| Total Complexity | 8 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 17 | class ContextUnpacking implements Layered |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * @var array |
||
| 21 | */ |
||
| 22 | protected $keys = []; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @param string ...$allowed |
||
| 26 | */ |
||
| 27 | public function keys(string ...$allowed) : void |
||
| 30 | } |
||
| 31 | |||
| 32 | public function inbound($request, Context $ctx) |
||
| 33 | { |
||
| 34 | /** |
||
| 35 | * @var Request $http |
||
| 36 | */ |
||
| 37 | $http = $ctx->get(ServerWrapper::REQUESTING); |
||
| 38 | |||
| 39 | if ($dat = $http->getHeaderLine(ContextPacking::HTTP_HEADER)) { |
||
| 40 | if ($attachments = json_decode(base64_decode($dat), true)) { |
||
| 41 | foreach ($attachments as $key => $val) { |
||
| 42 | in_array($key, $this->keys) && $ctx->set($key, $val); |
||
| 43 | } |
||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | return $request; |
||
| 48 | } |
||
| 49 | |||
| 50 | public function outbound($response, Context $ctx) |
||
| 51 | { |
||
| 52 | return $response; |
||
| 53 | } |
||
| 54 | |||
| 55 | public function exception(Throwable $e, Context $ctx) |
||
| 58 | } |
||
| 59 | } |
||
| 60 |