-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleRequestAdapter.php
More file actions
50 lines (48 loc) · 1.33 KB
/
SimpleRequestAdapter.php
File metadata and controls
50 lines (48 loc) · 1.33 KB
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
<?php
namespace charris\PODataSimple;
use POData\Common\ODataConstants;
use POData\OperationContext\HTTPRequestMethod;
use POData\OperationContext\IHTTPRequest;
use POData\OperationContext\Web\IncomingRequest;
class SimpleRequestAdapter extends IncomingRequest implements IHTTPRequest
{
protected $request;
public function __construct($request)
{
$this->request = $request;
}
/**
* get the raw incoming url
*
* @return string RequestURI called by User with the value of QueryString
*/
public function getRawUrl()
{
return $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . '/' . $_SERVER['REQUEST_URI'];
}
/**
* Returns the Query String Parameters (QSPs) as an array of KEY-VALUE pairs. If a QSP appears twice
* it will have two entries in this array
*
* @return array[]
*/
public function getQueryParameters()
{
$data = [];
if (is_array($this->request)) {
foreach ($this->request as $key => $value) {
$data[] = [$key => $value];
}
}
return $data;
}
/**
* Get the HTTP method/verb of the HTTP Request
*
* @return HTTPRequestMethod
*/
public function getMethod()
{
return new HTTPRequestMethod($_SERVER['REQUEST_METHOD']);
}
}