| Conditions | 5 |
| Paths | 4 |
| Total Lines | 17 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | public static function fromSuperGlobals(string $inputStream = 'php://input'): Body |
||
| 14 | { |
||
| 15 | $content = file_get_contents($inputStream); |
||
| 16 | if (empty($content)) { |
||
| 17 | return new EmptyBody(); |
||
| 18 | } |
||
| 19 | |||
| 20 | if (!isset($_SERVER['CONTENT_TYPE']) || empty($_SERVER['CONTENT_TYPE'])) { |
||
| 21 | return new RawBody($content); |
||
| 22 | } |
||
| 23 | |||
| 24 | switch ($_SERVER['CONTENT_TYPE']) { |
||
| 25 | case ContentType::JSON: |
||
| 26 | return new JsonBody($content); |
||
| 27 | } |
||
| 28 | throw new UnsupportedRequestBodyException(); |
||
| 29 | } |
||
| 30 | |||
| 36 |