| Conditions | 5 |
| Paths | 5 |
| Total Lines | 26 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 32 | public function buildParameters(string $url, string $method, array $parameters) |
||
| 33 | { |
||
| 34 | if (!is_array($this->parameters)) { |
||
| 35 | throw new \InvalidArgumentException('$parameters should be of type array'); |
||
| 36 | } |
||
| 37 | |||
| 38 | // merge query string from the url |
||
| 39 | $extractedQueryFromUrl = parse_url($url, PHP_URL_QUERY); |
||
| 40 | |||
| 41 | if (strlen($extractedQueryFromUrl) > 0) { |
||
| 42 | parse_str($extractedQueryFromUrl, $queryArray); |
||
| 43 | |||
| 44 | $parameters = array_merge($parameters, $queryArray); |
||
| 45 | } |
||
| 46 | |||
| 47 | if ('POST' === $method || 'PUT' === $method) { |
||
| 48 | return [ |
||
| 49 | 'query' => $parameters, |
||
| 50 | 'form_params' => $this->parameters, |
||
| 51 | ]; |
||
| 52 | } |
||
| 53 | |||
| 54 | return [ |
||
| 55 | 'query' => array_merge($parameters, $this->parameters), |
||
| 56 | ]; |
||
| 57 | } |
||
| 58 | } |
||
| 59 |