1 | <?php |
||
8 | abstract class AbstractRequest |
||
9 | { |
||
10 | /** |
||
11 | * @var array |
||
12 | */ |
||
13 | public static $allowedMethod = []; |
||
14 | |||
15 | /** |
||
16 | * @var ClientInterface |
||
17 | */ |
||
18 | protected $guzzle; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $login; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $password; |
||
29 | |||
30 | public function __construct(ClientInterface $client) |
||
34 | |||
35 | |||
36 | /** |
||
37 | * @param string $login |
||
38 | * @param string $password |
||
39 | * @return $this |
||
40 | */ |
||
41 | public function setCredentials($login, $password) |
||
48 | |||
49 | /** |
||
50 | * Make the request to API |
||
51 | * |
||
52 | * @param string $action |
||
53 | * @param array $params |
||
54 | * @param string $method |
||
55 | * @return array|null |
||
56 | * @throws \GuzzleHttp\Exception\GuzzleException |
||
57 | */ |
||
58 | public function exec($action, $params = [], $method = 'GET') |
||
76 | |||
77 | /** |
||
78 | * @param array $params |
||
79 | * @return string|array |
||
80 | */ |
||
81 | protected function createRequestBody(array $params) |
||
95 | |||
96 | /** |
||
97 | * @param string $method |
||
98 | * @param string|array $requestBody |
||
99 | * @return array |
||
100 | */ |
||
101 | private function makeOptions($method, $requestBody) |
||
112 | |||
113 | /** |
||
114 | * @param array $requestBody |
||
115 | * @return string|array |
||
116 | */ |
||
117 | abstract protected function formatRequestBody(array $requestBody); |
||
118 | |||
119 | /** |
||
120 | * @param string $response |
||
121 | * @return array |
||
122 | */ |
||
123 | abstract protected function parseResponse($response); |
||
124 | |||
125 | /** |
||
126 | * @param string $action |
||
127 | * @return string |
||
128 | */ |
||
129 | abstract protected function makeEndPoint($action); |
||
130 | } |
||
131 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.