| Conditions | 5 |
| Paths | 4 |
| Total Lines | 28 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 20 |
| CRAP Score | 5.0026 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 24 | 7 | private function formatMessage(string $message = null, $previous = null): string |
|
| 25 | { |
||
| 26 | 7 | $this->previous = $previous instanceof \Throwable |
|
| 27 | ? [$previous] |
||
| 28 | 7 | : iterable_to_array($previous ?? /* @scrutinizer ignore-type */ [], false); |
|
| 29 | 7 | $count = count($this->previous); |
|
| 30 | |||
| 31 | 7 | $message = sprintf( |
|
| 32 | 7 | rtrim($message ?? 'Generated %d %s', " \n\r\t\v\x00.:"), |
|
| 33 | 7 | $count, |
|
| 34 | 7 | 1 == $count ? 'exception' : 'exceptions' |
|
| 35 | 7 | ); |
|
| 36 | |||
| 37 | 7 | if ($count > 0) { |
|
| 38 | 2 | $message .= ":\n\n"; |
|
| 39 | 2 | foreach ($this->previous as $idx => $err) { |
|
| 40 | 2 | $message .= sprintf( |
|
| 41 | 2 | "% 3d. [%s] %s.\n", |
|
| 42 | 2 | $idx + 1, |
|
| 43 | 2 | get_class($err), |
|
| 44 | 2 | trim($err->getMessage(), " \n\r\t\v\x00.:") |
|
| 45 | 2 | ); |
|
| 46 | } |
||
| 47 | } else { |
||
| 48 | 6 | $message .= '.'; |
|
| 49 | } |
||
| 50 | |||
| 51 | 7 | return $message; |
|
| 52 | } |
||
| 66 |