| Total Complexity | 6 |
| Total Lines | 69 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | class QueryParams |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * The instance's query params. |
||
| 9 | * |
||
| 10 | * @var array |
||
| 11 | */ |
||
| 12 | protected $params; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Make a new QueryParams instance. |
||
| 16 | * |
||
| 17 | * @param array $params |
||
| 18 | */ |
||
| 19 | public function __construct(array $params) |
||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Build a full query string working around {@see http_build_query()}'s flaws. |
||
| 26 | * |
||
| 27 | * @return string |
||
| 28 | */ |
||
| 29 | public function build() |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Build query params for the API. |
||
| 40 | * |
||
| 41 | * @param string|array|int $value |
||
| 42 | * @param string $key |
||
| 43 | * @return string |
||
| 44 | */ |
||
| 45 | protected function buildQueryParams($value, string $key) |
||
| 46 | { |
||
| 47 | if (is_array($value)) { |
||
| 48 | return $this->buildQueryArray($key, $value); |
||
| 49 | } |
||
| 50 | |||
| 51 | return rawurlencode($key) . '=' . rawurlencode($value); |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Build a query array. {@see http_build_query()} shows you why this is needed! |
||
| 56 | * |
||
| 57 | * @param string $name |
||
| 58 | * @param array $value |
||
| 59 | * @return string |
||
| 60 | */ |
||
| 61 | protected function buildQueryArray(string $name, array $value) |
||
| 74 | } |
||
| 75 | } |
||
| 76 |