1 | <?php |
||
17 | class Builder |
||
18 | { |
||
19 | const METHOD_DELETE = 0; |
||
20 | const METHOD_GET = 1; |
||
21 | const METHOD_PATCH = 2; |
||
22 | const METHOD_POST = 3; |
||
23 | const METHOD_PUT = 4; |
||
24 | |||
25 | /** @var boolean */ |
||
26 | private $asJson; |
||
27 | |||
28 | /** @var null|string|array */ |
||
29 | private $data; |
||
30 | |||
31 | /** @var array|ResponseBehaviourInterface[] */ |
||
32 | private $defaultResponseBehaviours; |
||
33 | |||
34 | /** @var Merge */ |
||
35 | private $merge; |
||
36 | |||
37 | /** @var int */ |
||
38 | private $method; |
||
39 | |||
40 | /** @var array */ |
||
41 | private $parameters; |
||
42 | |||
43 | /** @var Request */ |
||
44 | private $request; |
||
45 | |||
46 | /** @var array|ResponseBehaviourInterface[] */ |
||
47 | private $responseBehaviours; |
||
48 | |||
49 | /** @var string */ |
||
50 | private $url; |
||
51 | |||
52 | /** |
||
53 | * @param Request $request |
||
54 | * @param Merge $merge |
||
55 | * @param array|ResponseBehaviourInterface[] $defaultResponseBehaviours |
||
56 | */ |
||
57 | public function __construct(Request $request, Merge $merge, array $defaultResponseBehaviours = array()) |
||
64 | |||
65 | /** |
||
66 | * @return Response |
||
67 | * @throws Exception|RuntimeException |
||
68 | */ |
||
69 | public function andFetchTheResponse() |
||
113 | |||
114 | /** |
||
115 | * @return $this |
||
116 | */ |
||
117 | public function asJson() |
||
125 | |||
126 | /** |
||
127 | * @param bool $alsoTheDefaults |
||
128 | * @return $this |
||
129 | */ |
||
130 | public function reset($alsoTheDefaults = false) |
||
141 | |||
142 | /** |
||
143 | * @param string $url |
||
144 | * @return $this |
||
145 | */ |
||
146 | public function onTheUrl($url) |
||
152 | |||
153 | /** |
||
154 | * @param null|string|array $data |
||
155 | * @return $this |
||
156 | */ |
||
157 | public function withTheData($data) |
||
163 | |||
164 | /** |
||
165 | * @param HeadLineInterface $line |
||
166 | * @return $this |
||
167 | */ |
||
168 | public function withTheHeaderLine(HeadLineInterface $line) |
||
174 | |||
175 | /** |
||
176 | * @param OptionInterface $option |
||
177 | * @return $this |
||
178 | */ |
||
179 | public function withTheOption(OptionInterface $option) |
||
185 | |||
186 | /** |
||
187 | * @param array $parameters |
||
188 | * @return $this |
||
189 | */ |
||
190 | public function withTheParameters(array $parameters) |
||
196 | |||
197 | /** |
||
198 | * @param string $line |
||
199 | * @return $this |
||
200 | */ |
||
201 | public function withTheRawHeaderLine($line) |
||
207 | |||
208 | /** |
||
209 | * @param string $key |
||
210 | * @param string $value |
||
211 | * @return $this |
||
212 | */ |
||
213 | public function withTheRawOption($key, $value) |
||
219 | |||
220 | /** |
||
221 | * @param ResponseBehaviourInterface $behaviour |
||
222 | * @return $this |
||
223 | */ |
||
224 | public function withTheResponseBehaviour(ResponseBehaviourInterface $behaviour) |
||
230 | |||
231 | //@todo better nameing? |
||
232 | // callDelete |
||
233 | /** |
||
234 | * @return $this |
||
235 | */ |
||
236 | public function useDelete() |
||
242 | |||
243 | /** |
||
244 | * @return $this |
||
245 | */ |
||
246 | public function useGet() |
||
252 | |||
253 | /** |
||
254 | * @return $this |
||
255 | */ |
||
256 | public function usePatch() |
||
262 | |||
263 | /** |
||
264 | * @return $this |
||
265 | */ |
||
266 | public function usePost() |
||
272 | |||
273 | /** |
||
274 | * @return $this |
||
275 | */ |
||
276 | public function usePut() |
||
282 | } |
||
283 |