| Total Complexity | 8 |
| Total Lines | 47 |
| 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 | private const CONTENT_TYPE = 'x-www-form-urlencoded'; |
||
| 14 | |||
| 15 | public function __construct() |
||
| 16 | { |
||
| 17 | $this->data = []; |
||
| 18 | } |
||
| 19 | |||
| 20 | public function getBody($content): array |
||
| 21 | { |
||
| 22 | if (is_array($content)) { |
||
| 23 | return $content; |
||
| 24 | } |
||
| 25 | |||
| 26 | $this->handleSentData($content); |
||
| 27 | |||
| 28 | return $this->data; |
||
| 29 | } |
||
| 30 | |||
| 31 | private function handleSentData(string $content): void |
||
| 32 | { |
||
| 33 | $body = explode('&', $content); |
||
| 34 | |||
| 35 | foreach ($body as $parameter) { |
||
| 36 | $parameterParsed = explode('=', $parameter); |
||
| 37 | |||
| 38 | $this->data[$parameterParsed[0]] = str_replace("%0A", "\n", $parameterParsed[1]); |
||
| 39 | } |
||
| 40 | } |
||
| 41 | |||
| 42 | public function next(Handler $handler) |
||
| 45 | } |
||
| 46 | |||
| 47 | public function handle($server): array |
||
| 54 | } |
||
| 55 | } |