Total Complexity | 3 |
Total Lines | 28 |
Duplicated Lines | 0 % |
Coverage | 85.71% |
Changes | 0 |
1 | <?php |
||
14 | 1 | class QueryMapper implements IMapper |
|
15 | { |
||
16 | |||
17 | /** |
||
18 | * Convert array or Traversable input to string output response |
||
19 | * @param string|object|iterable<string|int, mixed> $data |
||
20 | * @param bool $prettyPrint |
||
21 | */ |
||
22 | public function stringify(iterable|string|object $data, bool $prettyPrint = true): string |
||
23 | { |
||
24 | 1 | if ($data instanceof Traversable) { |
|
25 | $data = iterator_to_array($data); |
||
26 | } |
||
27 | 1 | return http_build_query((array) $data, '', '&'); |
|
28 | } |
||
29 | |||
30 | /** |
||
31 | * Convert client request data to array or traversable |
||
32 | * @param mixed $data |
||
33 | * @throws MappingException |
||
34 | * @return iterable<string|int, mixed> |
||
35 | * |
||
36 | */ |
||
37 | public function parse(mixed $data): iterable |
||
42 | } |
||
43 | } |
||
44 |