Lines
95.65%
22 / 23
Methods
0.00%
0 / 1
Classes
0.00%
0 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 95.65% | 22 / 23 | 0.00% | 0 / 1 | 9 | ||
| 16 | class Request extends SlimRequest implements \Psr\Http\Message\ServerRequestInterface | |
| 17 | { | |
| 18 | public function __construct( | |
| 19 | ?string $method = null, | |
| 20 | mixed $uri = null, | |
| 21 | mixed $body = 'php://memory', | |
| 22 | mixed $headers = array() | |
| 23 | ) { | |
| 24 | $cookies = []; | |
| 25 | $serverParams = $_SERVER; | |
| 26 | $uploadedFiles = []; | |
| 27 | if (!$uri instanceof UriInterface) { | |
| 28 | $uri = new Uri(is_string($uri) ? $uri : ''); | |
| 29 | } | |
| 30 | if (!$headers instanceof HeadersInterface) { | |
| 31 | $headers = new Headers(is_array($headers) ? $headers : []); | |
| 32 | } | |
| 33 | if (!$body instanceof StreamInterface) { | |
| 34 | if (!is_resource($body)) { | |
| 35 | $opened = fopen(is_string($body) ? $body : 'php://memory', 'w+b'); | |
| 36 | if ($opened === false) { | |
| 37 | throw new \RuntimeException('Unable to open request body stream'); | |
| 38 | } | |
| 39 | $body = $opened; | |
| 40 | } | |
| 41 | $body = new Stream($body); | |
| 42 | } | |
| 43 | parent::__construct( | |
| 44 | $method ?? 'GET', | |
| 45 | $uri, | |
| 46 | $headers, | |
| 47 | $cookies, | |
| 48 | $serverParams, | |
| 49 | $body, | |
| 50 | $uploadedFiles | |
| 51 | ); | |
| 52 | } | |
| 53 | } |