Test Failed
Push — upgrade-psr ( 3d23e3...7af4e6 )
by Sergei
17:47 queued 14:42
created

CompositeNotFoundException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 20
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Di;
6
7
use Exception;
8
use Psr\Container\ContainerInterface;
9
use Psr\Container\NotFoundExceptionInterface;
10
11
use function get_class;
12
13
/**
14
 * `CompositeNotFoundException` is thrown when no definition or class was found in the composite container
15
 * for a given ID. It contains all exceptions thrown by containers registered in the composite container.
16
 */
17
final class CompositeNotFoundException extends Exception implements NotFoundExceptionInterface
18
{
19
    /**
20
     * @param array $exceptions Container exceptions in [throwable, container] format.
21
     *
22
     * @psalm-param list<array{\Throwable,ContainerInterface}> $exceptions
23
     */
24
    public function __construct(array $exceptions)
25
    {
26
        $message = '';
27
28
        foreach ($exceptions as $i => [$exception, $container]) {
29
            $containerClass = get_class($container);
30
            $containerId = spl_object_id($container);
31
            $number = $i + 1;
32
33
            $message .= "\n    $number. Container $containerClass #$containerId: {$exception->getMessage()}";
34
        }
35
36
        parent::__construct(sprintf('No definition or class found or resolvable in composite container:%s', $message));
37
    }
38
}
39