@@ -8,7 +8,7 @@ |
||
| 8 | 8 | { |
| 9 | 9 | private Handler $handler; |
| 10 | 10 | |
| 11 | - private const CONTENT_TYPE = 'json'; |
|
| 11 | + private const CONTENT_TYPE = 'json'; |
|
| 12 | 12 | |
| 13 | 13 | public function getBody($content) |
| 14 | 14 | { |
@@ -11,34 +11,34 @@ |
||
| 11 | 11 | |
| 12 | 12 | private array $currentData; |
| 13 | 13 | |
| 14 | - private const CONTENT_TYPE = 'form-data'; |
|
| 14 | + private const CONTENT_TYPE = 'form-data'; |
|
| 15 | 15 | |
| 16 | 16 | public function __construct() |
| 17 | - { |
|
| 18 | - $this->currentData = []; |
|
| 19 | - } |
|
| 17 | + { |
|
| 18 | + $this->currentData = []; |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - public function getBody($content): array |
|
| 21 | + public function getBody($content): array |
|
| 22 | 22 | { |
| 23 | - $boundary = substr($content, 0, strpos($content, "\r\n")); |
|
| 24 | - $parts = array_slice(explode($boundary, $content), 1); |
|
| 23 | + $boundary = substr($content, 0, strpos($content, "\r\n")); |
|
| 24 | + $parts = array_slice(explode($boundary, $content), 1); |
|
| 25 | 25 | |
| 26 | - foreach ($parts as $part) { |
|
| 27 | - preg_match_all('/"(.+)"+\s+([^\t]+)/', $part, $matches); |
|
| 26 | + foreach ($parts as $part) { |
|
| 27 | + preg_match_all('/"(.+)"+\s+([^\t]+)/', $part, $matches); |
|
| 28 | 28 | |
| 29 | - $this->handleBodySent($matches); |
|
| 30 | - } |
|
| 29 | + $this->handleBodySent($matches); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - return $this->currentData; |
|
| 32 | + return $this->currentData; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - private function handleBodySent(array $matches): void |
|
| 36 | - { |
|
| 37 | - foreach ($matches[1] as $key => $match) { |
|
| 38 | - $matchKey = str_replace(["'", '"'], '', $match); |
|
| 35 | + private function handleBodySent(array $matches): void |
|
| 36 | + { |
|
| 37 | + foreach ($matches[1] as $key => $match) { |
|
| 38 | + $matchKey = str_replace(["'", '"'], '', $match); |
|
| 39 | 39 | |
| 40 | - $this->currentData[$matchKey] = substr($matches[2][$key], 0, -2); |
|
| 41 | - } |
|
| 40 | + $this->currentData[$matchKey] = substr($matches[2][$key], 0, -2); |
|
| 41 | + } |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | public function next(Handler $handler) |
@@ -6,26 +6,26 @@ |
||
| 6 | 6 | |
| 7 | 7 | class TextPlain implements Handler, Advancer |
| 8 | 8 | { |
| 9 | - private Handler $handler; |
|
| 9 | + private Handler $handler; |
|
| 10 | 10 | |
| 11 | - private const CONTENT_TYPE = 'text/plain'; |
|
| 11 | + private const CONTENT_TYPE = 'text/plain'; |
|
| 12 | 12 | |
| 13 | - public function getBody($content): array |
|
| 14 | - { |
|
| 15 | - return [$content]; |
|
| 16 | - } |
|
| 13 | + public function getBody($content): array |
|
| 14 | + { |
|
| 15 | + return [$content]; |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - public function next(Handler $handler) |
|
| 19 | - { |
|
| 20 | - $this->handler = $handler; |
|
| 21 | - } |
|
| 18 | + public function next(Handler $handler) |
|
| 19 | + { |
|
| 20 | + $this->handler = $handler; |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - public function handle($server): array |
|
| 24 | - { |
|
| 25 | - if (ContentHelper::contentIs($server, self::CONTENT_TYPE)) { |
|
| 26 | - return $this->getBody($server->getContent()); |
|
| 27 | - } |
|
| 23 | + public function handle($server): array |
|
| 24 | + { |
|
| 25 | + if (ContentHelper::contentIs($server, self::CONTENT_TYPE)) { |
|
| 26 | + return $this->getBody($server->getContent()); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - return $this->handler->handle($server); |
|
| 30 | - } |
|
| 29 | + return $this->handler->handle($server); |
|
| 30 | + } |
|
| 31 | 31 | } |
| 32 | 32 | \ No newline at end of file |
@@ -13,30 +13,30 @@ |
||
| 13 | 13 | private const CONTENT_TYPE = 'x-www-form-urlencoded'; |
| 14 | 14 | |
| 15 | 15 | public function __construct() |
| 16 | - { |
|
| 17 | - $this->data = []; |
|
| 18 | - } |
|
| 16 | + { |
|
| 17 | + $this->data = []; |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - public function getBody($content): array |
|
| 20 | + public function getBody($content): array |
|
| 21 | 21 | { |
| 22 | - if (is_array($content)) { |
|
| 23 | - return $content; |
|
| 24 | - } |
|
| 22 | + if (is_array($content)) { |
|
| 23 | + return $content; |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - $this->handleSentData($content); |
|
| 26 | + $this->handleSentData($content); |
|
| 27 | 27 | |
| 28 | - return $this->data; |
|
| 28 | + return $this->data; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - private function handleSentData(string $content): void |
|
| 32 | - { |
|
| 33 | - $body = explode('&', $content); |
|
| 31 | + private function handleSentData(string $content): void |
|
| 32 | + { |
|
| 33 | + $body = explode('&', $content); |
|
| 34 | 34 | |
| 35 | - foreach ($body as $parameter) { |
|
| 36 | - $parameterParsed = explode('=', $parameter); |
|
| 35 | + foreach ($body as $parameter) { |
|
| 36 | + $parameterParsed = explode('=', $parameter); |
|
| 37 | 37 | |
| 38 | - $this->data[$parameterParsed[0]] = str_replace("%0A", "\n", $parameterParsed[1]); |
|
| 39 | - } |
|
| 38 | + $this->data[$parameterParsed[0]] = str_replace("%0A", "\n", $parameterParsed[1]); |
|
| 39 | + } |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function next(Handler $handler) |