1 | <?php |
||
11 | trait MakesHttpRequests |
||
12 | { |
||
13 | /** |
||
14 | * @param string $uri |
||
15 | * |
||
16 | * @return mixed |
||
17 | */ |
||
18 | protected function get(string $uri) |
||
22 | |||
23 | /** |
||
24 | * @param string $uri |
||
25 | * @param array $payload |
||
26 | * |
||
27 | * @return mixed |
||
28 | */ |
||
29 | protected function post(string $uri, array $payload = []) |
||
33 | |||
34 | /** |
||
35 | * @param string $uri |
||
36 | * @param array $payload |
||
37 | * |
||
38 | * @return mixed |
||
39 | */ |
||
40 | protected function put(string $uri, array $payload = []) |
||
44 | |||
45 | /** |
||
46 | * @param string $uri |
||
47 | * @param array $payload |
||
48 | * |
||
49 | * @return mixed |
||
50 | */ |
||
51 | protected function delete(string $uri, array $payload = []) |
||
55 | |||
56 | /** |
||
57 | * @param string $verb |
||
58 | * @param string $uri |
||
59 | * @param array $payload |
||
60 | * |
||
61 | * @return mixed |
||
62 | */ |
||
63 | protected function request(string $verb, string $uri, array $payload = []) |
||
77 | |||
78 | public function isSuccessFul($response): bool |
||
86 | |||
87 | protected function handleRequestError(ResponseInterface $response) |
||
103 | } |
||
104 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: