| Conditions | 5 |
| Paths | 3 |
| Total Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 29 | 604 | public static function fromGlobals( |
|
| 30 | array $server = null, |
||
| 31 | array $query = null, |
||
| 32 | array $body = null, |
||
| 33 | array $cookies = null, |
||
| 34 | array $files = null |
||
| 35 | ) : ServerRequest { |
||
| 36 | 604 | ||
| 37 | 604 | $request = parent::fromGlobals($server, $query, $body, $cookies, $files); |
|
| 38 | 604 | ||
| 39 | 604 | $contentType = current($request->getHeader('Content-Type')); |
|
| 40 | 604 | ||
| 41 | 604 | // support header like "application/json" and "application/json; charset=utf-8" |
|
| 42 | 604 | if (false !== $contentType && false !== stripos($contentType, Request::TYPE_JSON)) { |
|
| 43 | 604 | $input = file_get_contents('php://input'); |
|
| 44 | 604 | $data = (array) json_decode($input); |
|
| 45 | 604 | } elseif ($request->getMethod() === RequestMethod::POST) { |
|
| 46 | $data = $_POST; |
||
| 47 | } else { |
||
| 48 | 604 | $input = file_get_contents('php://input'); |
|
| 49 | parse_str($input, $data); |
||
| 50 | 604 | } |
|
| 51 | |||
| 52 | return $request->withParsedBody($body ?: $data); |
||
| 53 | 604 | } |
|
| 54 | } |
||
| 55 |