/
CouchRequest.class.php
executable file
·86 lines (72 loc) · 1.51 KB
/
CouchRequest.class.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
<?php
/**
*
*/
class CouchRequest
{
protected
$query = null,
$parameters = null,
$method = "get",
$data = null;
public function __construct($method = "GET", $query = "", $parameters = array(), CouchData $data = null)
{
$this->method = $method;
$this->query = $query;
if ($parameters instanceof CouchData)
{
$data = $parameters;
$parameters = array();
}
$this->parameters = $parameters;
$this->data = $data;
}
/**
* builds the requested object. This method should be overridden without calling
* parent::buildObjectFromResponse
* extend this method to request different objects from the response
*
* @return object
* @author The Young Shepherd
**/
public function buildObjectFromResponse(CouchResponse $response)
{
return new CouchData($response->getBody(), true);
}
public function getQuery()
{
return $this->query;
}
public function setQuery($value)
{
$this->query = $value;
}
public function getParameters()
{
return $this->parameters;
}
public function setParameters(array $value)
{
$this->parameters = $value;
}
public function getMethod()
{
return $this->method;
}
public function setMethod($value)
{
$this->method = $value;
}
public function getData()
{
return $this->data;
}
public function setData(CouchData $value)
{
$this->data = $value;
}
public function send(CouchQueryable $object)
{
return $object->send($this);
}
}