Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
10 / 10 |
|
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| ResetFailed | |
100.00% |
10 / 10 |
|
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
10 / 10 |
|
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Celema\Container\Exception; |
| 6 | |
| 7 | use Throwable; |
| 8 | |
| 9 | /** |
| 10 | * Thrown by `Container::reset()` after every reset hook was attempted and the |
| 11 | * scope was cleared. The first failure is the previous exception. |
| 12 | * |
| 13 | * @psalm-api |
| 14 | */ |
| 15 | final class ResetFailed extends ContainerException |
| 16 | { |
| 17 | /** @param non-empty-list<Throwable> $failures */ |
| 18 | public function __construct( |
| 19 | public readonly array $failures, |
| 20 | ) { |
| 21 | $count = count($failures); |
| 22 | |
| 23 | parent::__construct( |
| 24 | sprintf( |
| 25 | '%d reset hook%s failed while resetting a container scope. First failure: %s', |
| 26 | $count, |
| 27 | $count === 1 ? '' : 's', |
| 28 | $failures[0]->getMessage(), |
| 29 | ), |
| 30 | previous: $failures[0], |
| 31 | ); |
| 32 | } |
| 33 | } |