Completed
Push — master ( e2ffe7...d0248d )
by Biao
08:23 queued 06:02
created

Request::toIlluminateRequest()   B

Complexity

Conditions 9
Paths 128

Size

Total Lines 20
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 9
eloc 14
nc 128
nop 0
dl 0
loc 20
rs 7
c 0
b 0
f 0
1
<?php
2
3
namespace Hhxsv5\LaravelS\Swoole;
4
5
use Illuminate\Http\Request as IlluminateRequest;
0 ignored issues
show
Bug introduced by
The type Illuminate\Http\Request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Symfony\Component\HttpFoundation\HeaderBag;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpFoundation\HeaderBag was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
class Request
9
{
10
    protected $swooleRequest;
11
12
    public function __construct(\swoole_http_request $request)
0 ignored issues
show
Bug introduced by
The type swoole_http_request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
    {
14
        $this->swooleRequest = $request;
15
    }
16
17
    public function toIlluminateRequest()
18
    {
19
        $get = isset($this->swooleRequest->get) ? $this->swooleRequest->get : [];
20
        $post = isset($this->swooleRequest->post) ? $this->swooleRequest->post : [];
21
        $cookies = isset($this->swooleRequest->cookie) ? $this->swooleRequest->cookie : [];
22
        $server = isset($this->swooleRequest->server) ? $this->swooleRequest->server : [];
23
        $headers = isset($this->swooleRequest->header) ? $this->swooleRequest->header : [];
24
        $files = isset($this->swooleRequest->files) ? $this->swooleRequest->files : [];
25
26
        foreach ($headers as $key => $value) {
27
            $key = str_replace('-', '_', $key);
28
            $server['http_' . $key] = $value;
29
        }
30
        $server = array_change_key_case($server, CASE_UPPER);
31
32
        $content = $this->swooleRequest->rawContent() ?: null;
33
        $laravelRequest = new IlluminateRequest($get, $post, [], $cookies, $files, $server, $content);
34
        $laravelRequest->headers = new HeaderBag($headers);
35
36
        return $laravelRequest;
37
    }
38
39
}
40