1 | <?php |
||
21 | trait HttpAdapterTrait |
||
22 | { |
||
23 | /** |
||
24 | * @param string|object $uri |
||
25 | * @param array $headers |
||
26 | * |
||
27 | * @throws HttpAdapterException |
||
28 | * |
||
29 | * @return ResponseInterface |
||
30 | */ |
||
31 | 375 | public function get($uri, array $headers = []) |
|
35 | |||
36 | /** |
||
37 | * @param string|object $uri |
||
38 | * @param array $headers |
||
39 | * |
||
40 | * @throws HttpAdapterException |
||
41 | * |
||
42 | * @return ResponseInterface |
||
43 | */ |
||
44 | 366 | public function head($uri, array $headers = []) |
|
48 | |||
49 | /** |
||
50 | * @param string|object $uri |
||
51 | * @param array $headers |
||
52 | * |
||
53 | * @throws HttpAdapterException |
||
54 | * |
||
55 | * @return ResponseInterface |
||
56 | */ |
||
57 | 2905 | public function trace($uri, array $headers = []) |
|
61 | |||
62 | /** |
||
63 | * @param string|object $uri |
||
64 | * @param array $headers |
||
65 | * @param array|string $datas |
||
66 | * @param array $files |
||
67 | * |
||
68 | * @throws HttpAdapterException |
||
69 | * |
||
70 | * @return ResponseInterface |
||
71 | */ |
||
72 | 915 | public function post($uri, array $headers = [], $datas = [], array $files = []) |
|
76 | |||
77 | /** |
||
78 | * @param string|object $uri |
||
79 | * @param array $headers |
||
80 | * @param array|string $datas |
||
81 | * @param array $files |
||
82 | * |
||
83 | * @throws HttpAdapterException |
||
84 | * |
||
85 | * @return ResponseInterface |
||
86 | */ |
||
87 | 732 | public function put($uri, array $headers = [], $datas = [], array $files = []) |
|
91 | |||
92 | /** |
||
93 | * @param string|object $uri |
||
94 | * @param array $headers |
||
95 | * @param array|string $datas |
||
96 | * @param array $files |
||
97 | * |
||
98 | * @throws HttpAdapterException |
||
99 | * |
||
100 | * @return ResponseInterface |
||
101 | */ |
||
102 | 732 | public function patch($uri, array $headers = [], $datas = [], array $files = []) |
|
106 | |||
107 | /** |
||
108 | * @param string|object $uri |
||
109 | * @param array $headers |
||
110 | * @param array|string $datas |
||
111 | * @param array $files |
||
112 | * |
||
113 | * @throws HttpAdapterException |
||
114 | * |
||
115 | * @return ResponseInterface |
||
116 | */ |
||
117 | 732 | public function delete($uri, array $headers = [], $datas = [], array $files = []) |
|
121 | |||
122 | /** |
||
123 | * @param string|object $uri |
||
124 | * @param array $headers |
||
125 | * @param array|string $datas |
||
126 | * @param array $files |
||
127 | * |
||
128 | * @throws HttpAdapterException |
||
129 | * |
||
130 | * @return ResponseInterface |
||
131 | */ |
||
132 | 732 | public function options($uri, array $headers = [], $datas = [], array $files = []) |
|
136 | |||
137 | /** |
||
138 | * @param string|object $uri |
||
139 | * @param string $method |
||
140 | * @param array $headers |
||
141 | * @param array|string $datas |
||
142 | * @param array $files |
||
143 | * |
||
144 | * @throws HttpAdapterException |
||
145 | * |
||
146 | * @return ResponseInterface |
||
147 | */ |
||
148 | 10239 | public function send($uri, $method, array $headers = [], $datas = [], array $files = []) |
|
159 | |||
160 | /** |
||
161 | * @param RequestInterface $request |
||
162 | * |
||
163 | * @throws HttpAdapterException |
||
164 | * |
||
165 | * @return ResponseInterface |
||
166 | */ |
||
167 | 15114 | public function sendRequest(RequestInterface $request) |
|
187 | |||
188 | /** |
||
189 | * @param array $requests |
||
190 | * |
||
191 | * @throws MultiHttpAdapterException |
||
192 | * |
||
193 | * @return array |
||
194 | */ |
||
195 | 456 | public function sendRequests(array $requests) |
|
241 | |||
242 | /** |
||
243 | * @param InternalRequestInterface $internalRequest |
||
244 | * |
||
245 | * @throws HttpAdapterException |
||
246 | * |
||
247 | * @return ResponseInterface |
||
248 | */ |
||
249 | abstract protected function sendInternalRequest(InternalRequestInterface $internalRequest); |
||
250 | |||
251 | /** |
||
252 | * @param array $internalRequests |
||
253 | * @param callable $success |
||
254 | * @param callable $error |
||
255 | * |
||
256 | * @throws MultiHttpAdapterException |
||
257 | * |
||
258 | * @return array |
||
259 | */ |
||
260 | 301 | protected function sendInternalRequests(array $internalRequests, $success, $error) |
|
274 | } |
||
275 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.