Issues (26)

src/Http.php (1 issue)

Severity
1
<?php
2
3
namespace Raptor\Request;
4
5
use Raptor\Request\Components\Line;
6
use Raptor\Request\Components\Header;
7
use Raptor\Request\Components\Body;
8
9
class Http
10
{
11
    /**
12
     * request-line (see https://tools.ietf.org/html/rfc7230#section-3.1.1)
13
     *
14
     * @var \Raptor\Request\Components\Line
15
     */
16
    protected $line;
17
    
18
    /**
19
     * request-header (see https://tools.ietf.org/html/rfc7230#section-3.2)
20
     *
21
     * @var \Raptor\Request\Components\Header
22
     */
23
    protected $header;
24
    
25
    /**
26
     * message-body (see https://tools.ietf.org/html/rfc7230#section-3.3)
27
     *
28
     * @var \Raptor\Request\Components\Body
29
     */
30
    protected $body;
31
32
    /**
33
     * Class constructor
34
     */
35
    public function __construct()
36
    {
37
        $this->line = new Line;
38
        $this->header = new Header;
39
        $this->body = new Body;
40
    }
41
42
    /**
43
     * Get the request-line.
44
     *
45
     * @return \Raptor\Request\Components\Line
46
     */
47
    public function line()
48
    {
49
        return $this->line;
50
    }
51
52
    /**
53
     * Get the request-header.
54
     *
55
     * @return \Raptor\Request\Components\Header
56
     */
57
    public function header()
58
    {
59
        return $this->header;
60
    }
61
62
    /**
63
     * Get the message-body.
64
     *
65
     * @return \Raptor\Request\Components\Body
66
     */
67
    public function body()
68
    {
69
        return $this->body;
70
    }
71
72
    /**
73
     * Get the method token from request-line.
74
     *
75
     * @return  string
76
     */
77
    public function method()
78
    {
79
        return $this->line()->method();
80
    }
81
82
    /**
83
     * Get the query string from request-target of request-line.
84
     *
85
     * @param  string $key (optional)
86
     * @param  mixed $default (optional)
87
     * @return  mixed
88
     */
89
    public function query($key = null, $default = null)
90
    {
91
        return $this->line()->target()->query($key, $default);
92
    }
93
94
    /**
95
     * Get the cookies from request-header.
96
     *
97
     * @param  string $key (optional)
98
     * @param  mixed $default (optional)
99
     * @return  mixed
100
     */
101
    public function cookie($key = null, $default = null)
102
    {
103
        return $this->header()->cookie($key, $default);
104
    }
105
106
    /**
107
     * Get the param from message-body.
108
     *
109
     * @param  string $key (optional)
110
     * @param  mixed $default (optional)
111
     * @return  mixed
112
     */
113
    public function param($key = null, $default = null)
114
    {
115
        return $this->body()->param($key, $default);
116
    }
117
118
    /**
119
     * Get the uploaded files from message-body.
120
     *
121
     * @param  string $key (optional)
122
     * @param  mixed $default (optional)
123
     * @return  mixed
124
     */
125
    public function uploads($key = null, $default = null)
126
    {
127
        return $this->body()->files($key, $default);
0 ignored issues
show
The call to Raptor\Request\Components\Body::files() has too many arguments starting with $default. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

127
        return $this->body()->/** @scrutinizer ignore-call */ files($key, $default);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
128
    }
129
130
    /**
131
     * Get the authorization header-field from request-header.
132
     *
133
     * @return  \Raptor\Request\Components\Authorization
134
     */
135
    public function auth()
136
    {
137
        return $this->header()->authorization();
138
    }
139
}