| Conditions | 8 |
| Paths | 6 |
| Total Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 8 |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | 6 | public function format(array $arguments, bool $recursive = true): string |
|
| 27 | { |
||
| 28 | 6 | $result = []; |
|
| 29 | |||
| 30 | 6 | foreach ($arguments as $argument) { |
|
| 31 | switch (true) { |
||
| 32 | 4 | case is_string($argument): |
|
| 33 | 2 | $result[] = '"' . $argument . '"'; |
|
| 34 | 2 | break; |
|
| 35 | 3 | case is_array($argument): |
|
| 36 | 2 | $associative = array_keys($argument) !== range(0, count($argument) - 1); |
|
| 37 | 2 | if ($recursive && $associative && count($argument) <= 5) { |
|
| 38 | 1 | $result[] = '[' . $this->format($argument, false) . ']'; |
|
| 39 | } |
||
| 40 | 2 | break; |
|
| 41 | 2 | case is_object($argument): |
|
| 42 | 2 | $class = get_class($argument); |
|
| 43 | 2 | $result[] = "Object($class)"; |
|
| 44 | 4 | break; |
|
| 45 | } |
||
| 46 | } |
||
| 47 | |||
| 48 | 6 | return implode(', ', $result); |
|
| 49 | } |
||
| 50 | } |
||
| 51 |