1 | <?php |
||
5 | abstract class AbstractApi |
||
6 | { |
||
7 | protected $client; |
||
8 | protected $uri; |
||
9 | protected $ids = null; |
||
10 | protected $page = 1; |
||
11 | protected $arguments = []; |
||
12 | protected $supportedFilters = []; |
||
13 | protected $model; |
||
14 | |||
15 | /** |
||
16 | * Send HTTP Request to API |
||
17 | * |
||
18 | * @param null $uri |
||
19 | * @param null $arguments |
||
20 | * @param bool $async |
||
21 | * @return mixed |
||
22 | */ |
||
23 | public function sendRequest($uri = null, $arguments = null, $async = false) |
||
46 | |||
47 | public function get($ids = null) |
||
53 | |||
54 | public function all() |
||
58 | |||
59 | /** |
||
60 | * @param array $params |
||
61 | * @return $this |
||
62 | */ |
||
63 | public function where(array $params) |
||
79 | |||
80 | /** |
||
81 | * You can set ids and add additional filters and then execute API request |
||
82 | * |
||
83 | * @param $ids |
||
84 | * @return AbstractApi |
||
85 | */ |
||
86 | public function whereId($ids) |
||
90 | |||
91 | /** |
||
92 | * Send raw uri to API |
||
93 | * @param string $uri |
||
94 | */ |
||
95 | public function raw(string $uri) |
||
99 | |||
100 | /** |
||
101 | * Clear all arguments and ids |
||
102 | * |
||
103 | * @return $this |
||
104 | */ |
||
105 | public function clear() |
||
112 | |||
113 | /** |
||
114 | * Get arguments/filters for API |
||
115 | * @return array |
||
116 | */ |
||
117 | public function getArguments() |
||
121 | |||
122 | /** |
||
123 | * Set page for request |
||
124 | * |
||
125 | * @param int $page |
||
126 | * @return $this |
||
127 | */ |
||
128 | public function setPage(int $page) |
||
135 | |||
136 | /** |
||
137 | * Increment page to simulate pagination |
||
138 | * @return $this |
||
139 | */ |
||
140 | public function nextPage() |
||
147 | |||
148 | /** |
||
149 | * Decrement page to simulate pagination |
||
150 | * @return $this |
||
151 | */ |
||
152 | public function previousPage() |
||
165 | |||
166 | /** |
||
167 | * Parse ids and prepare uri |
||
168 | * @param null $ids |
||
169 | * @return string |
||
170 | */ |
||
171 | public function getUri($ids = null) |
||
186 | |||
187 | /** |
||
188 | * Used for nesting where function with API filter values |
||
189 | * Example: whereName('Rick') will internally call where function with argument ['name' => 'Rick'] |
||
190 | * @param $name |
||
191 | * @param $arguments |
||
192 | * @return $this |
||
193 | */ |
||
194 | public function __call($name, $arguments) |
||
210 | } |
||
211 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.