1 | <?php |
||
19 | class Builder |
||
20 | { |
||
21 | const METHOD_DELETE = 0; |
||
22 | const METHOD_GET = 1; |
||
23 | const METHOD_PATCH = 2; |
||
24 | const METHOD_POST = 3; |
||
25 | const METHOD_PUT = 4; |
||
26 | |||
27 | /** @var boolean */ |
||
28 | private $asJson; |
||
29 | |||
30 | /** @var null|string|array */ |
||
31 | private $data; |
||
32 | |||
33 | /** @var array|ResponseBehaviourInterface[] */ |
||
34 | private $defaultResponseBehaviours; |
||
35 | |||
36 | /** @var Merge */ |
||
37 | private $merge; |
||
38 | |||
39 | /** @var int */ |
||
40 | private $method; |
||
41 | |||
42 | /** @var array */ |
||
43 | private $parameters; |
||
44 | |||
45 | /** @var Request */ |
||
46 | private $request; |
||
47 | |||
48 | /** @var array|ResponseBehaviourInterface[] */ |
||
49 | private $responseBehaviours; |
||
50 | |||
51 | /** @var string */ |
||
52 | private $url; |
||
53 | |||
54 | /** |
||
55 | * @param Request $request |
||
56 | * @param Merge $merge |
||
57 | * @param array|ResponseBehaviourInterface[] $defaultResponseBehaviours |
||
58 | */ |
||
59 | public function __construct(Request $request, Merge $merge, array $defaultResponseBehaviours = array()) |
||
66 | |||
67 | /** |
||
68 | * @return Response |
||
69 | * @throws Exception|RuntimeException |
||
70 | */ |
||
71 | public function andFetchTheResponse() |
||
115 | |||
116 | /** |
||
117 | * @return $this |
||
118 | */ |
||
119 | public function asJson() |
||
127 | |||
128 | /** |
||
129 | * @param bool $alsoTheDefaults |
||
130 | * @return $this |
||
131 | */ |
||
132 | public function reset($alsoTheDefaults = false) |
||
143 | |||
144 | /** |
||
145 | * @param string $url |
||
146 | * @return $this |
||
147 | */ |
||
148 | public function onTheUrl($url) |
||
154 | |||
155 | /** |
||
156 | * @param null|string|array $data |
||
157 | * @return $this |
||
158 | */ |
||
159 | public function withTheData($data) |
||
165 | |||
166 | /** |
||
167 | * @param HeaderLineInterface $line |
||
168 | * @return $this |
||
169 | */ |
||
170 | public function withTheHeaderLine(HeaderLineInterface $line) |
||
176 | |||
177 | /** |
||
178 | * @param OptionInterface $option |
||
179 | * @return $this |
||
180 | */ |
||
181 | public function withTheOption(OptionInterface $option) |
||
187 | |||
188 | /** |
||
189 | * @param array $parameters |
||
190 | * @return $this |
||
191 | */ |
||
192 | public function withTheParameters(array $parameters) |
||
198 | |||
199 | /** |
||
200 | * @param string $line |
||
201 | * @return $this |
||
202 | */ |
||
203 | public function withTheRawHeaderLine($line) |
||
209 | |||
210 | /** |
||
211 | * @param string $key |
||
212 | * @param string $value |
||
213 | * @return $this |
||
214 | */ |
||
215 | public function withTheRawOption($key, $value) |
||
221 | |||
222 | /** |
||
223 | * @param ResponseBehaviourInterface $behaviour |
||
224 | * @return $this |
||
225 | */ |
||
226 | public function withTheResponseBehaviour(ResponseBehaviourInterface $behaviour) |
||
232 | |||
233 | //@todo better nameing? |
||
234 | // callDelete |
||
235 | /** |
||
236 | * @return $this |
||
237 | */ |
||
238 | public function useDelete() |
||
244 | |||
245 | /** |
||
246 | * @return $this |
||
247 | */ |
||
248 | public function useGet() |
||
254 | |||
255 | /** |
||
256 | * @return $this |
||
257 | */ |
||
258 | public function usePatch() |
||
264 | |||
265 | /** |
||
266 | * @return $this |
||
267 | */ |
||
268 | public function usePost() |
||
274 | |||
275 | /** |
||
276 | * @return $this |
||
277 | */ |
||
278 | public function usePut() |
||
284 | } |
||
285 |