| Total Complexity | 8 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class FormUrlEncoded implements Handler, Advancer |
||
| 8 | { |
||
| 9 | private Handler $handler; |
||
| 10 | |||
| 11 | private array $data; |
||
| 12 | |||
| 13 | public function __construct() |
||
| 14 | { |
||
| 15 | $this->data = []; |
||
| 16 | } |
||
| 17 | |||
| 18 | public function getBody($content): array |
||
| 19 | { |
||
| 20 | if (is_array($content)) { |
||
| 21 | return $content; |
||
| 22 | } |
||
| 23 | |||
| 24 | $this->handleSentData($content); |
||
| 25 | |||
| 26 | return $this->data; |
||
| 27 | } |
||
| 28 | |||
| 29 | private function handleSentData(string $content): void |
||
| 30 | { |
||
| 31 | $body = explode('&', $content); |
||
| 32 | |||
| 33 | foreach ($body as $parameter) { |
||
| 34 | $parameterParsed = explode('=', $parameter); |
||
| 35 | |||
| 36 | $this->data[$parameterParsed[0]] = str_replace("%0A", "\n", $parameterParsed[1]); |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | public function next(Handler $handler) |
||
| 43 | } |
||
| 44 | |||
| 45 | public function handle($server): array |
||
| 52 | } |
||
| 53 | } |