-
Notifications
You must be signed in to change notification settings - Fork 0
/
Request.php
97 lines (82 loc) · 1.59 KB
/
Request.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/**
* Created by PhpStorm.
* User: fuerm
* Date: 18/8/27 027
* Time: 21:56
*/
class Request
{
const METHOD_GET = 'GET';
const METHOD_POST = 'POST';
/** @var string */
protected $path;
/** @var string */
protected $method;
/** @var RequestHeaders */
protected $headers;
/** @var array */
protected $query;
/** @var RequestBody */
protected $body;
/**
* Request constructor.
* @param string $path
* @param string $method
*/
public function __construct($path = '/', $method = self::METHOD_GET)
{
$this->path = $path;
$this->method = $method;
}
public function addHeader(Header $header)
{
$this->headers[] = $header;
}
/**
* @return RequestHeaders
*/
public function getHeaders()
{
return $this->headers;
}
/**
* @param RequestHeaders $headers
*/
public function setHeaders(RequestHeaders $headers)
{
$this->headers = $headers;
}
public function addQuery($key, $value)
{
$this->query[$key] = $value;
}
/**
* @return array
*/
public function getQuery()
{
return $this->query;
}
/**
* @param array $query
*/
public function setQuery(array $query)
{
$this->query = $query;
}
/**
* @return RequestBody
*/
public function getBody()
{
return $this->body;
}
/**
* @param RequestBody $body
*/
public function setBody(RequestBody $body)
{
$this->body = $body;
}
}