1 | <?php declare(strict_types=1); |
||
9 | class Utils |
||
10 | { |
||
11 | 115 | public static function jsonDecode(ResponseInterface $response, bool $assoc = true) |
|
38 | |||
39 | /** |
||
40 | * Method for flattening a nested array. |
||
41 | 94 | * |
|
42 | * @param array $data The nested array |
||
43 | 94 | * @param string $key The key to extract |
|
44 | * |
||
45 | * @return array |
||
46 | */ |
||
47 | public static function flattenJson($data, string $key = null) |
||
51 | |||
52 | /** |
||
53 | * Method for normalize an URL string. |
||
54 | * |
||
55 | * Append the http:// prefix if not present, and add a |
||
56 | 6 | * closing url separator when missing. |
|
57 | * |
||
58 | 6 | * @param string $url The url representation. |
|
59 | 6 | * |
|
60 | 6 | * @return string |
|
61 | */ |
||
62 | 6 | public static function normalizeUrl(string $url): string |
|
70 | |||
71 | /** |
||
72 | * Add an unlimited list of paths to a given URI. |
||
73 | 2 | * |
|
74 | * @param UriInterface $uri |
||
75 | 2 | * @param ...$paths |
|
76 | * |
||
77 | * @return UriInterface |
||
78 | 5 | */ |
|
79 | public static function addPaths(UriInterface $uri, ...$paths): UriInterface |
||
83 | |||
84 | public static function appendPath(UriInterface $uri, $path): UriInterface |
||
88 | } |
||
89 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: