Lines
60.00%
3 / 5
Functions and Methods
50.00%
1 / 2
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ChatTestHelpers | 60.00% | 3 / 5 | 50.00% | 1 / 2 | 6.60 | 0.00% | 0 / 1 | |||
| cause | 50.00% | 2 / 4 | 0.00% | 0 / 1 | 4.12 | |||||
| masked | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 2 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace App\Command; | |
| 6 | ||
| 7 | use Symfony\Component\Messenger\Exception\WrappedExceptionsInterface; | |
| 8 | ||
| 9 | /** | |
| 10 | * What app:slack:test and app:telegram:test share. | |
| 11 | */ | |
| 12 | trait ChatTestHelpers | |
| 13 | { | |
| 14 | /** The transport's exception, also when the message bus wrapped it. */ | |
| 15 | private function cause(\Throwable $exception): \Throwable | |
| 16 | { | |
| 17 | if ($exception instanceof WrappedExceptionsInterface) { | |
| 18 | foreach ($exception->getWrappedExceptions(recursive: true) as $wrapped) { | |
| 19 | return $wrapped; | |
| 20 | } | |
| 21 | } | |
| 22 | ||
| 23 | return $exception; | |
| 24 | } | |
| 25 | ||
| 26 | private function masked(string $token): string | |
| 27 | { | |
| 28 | return \strlen($token) > 12 ? \substr($token, 0, 9).'…'.\substr($token, -4) : '(too short: '.\strlen($token).' characters)'; | |
| 29 | } | |
| 30 | } |