CompositeNotFoundException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 20
ccs 8
cts 8
cp 1
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
/**
12
 * `CompositeNotFoundException` is thrown when no definition or class was found in the composite container
13
 * for a given ID. It contains all exceptions thrown by containers registered in the composite container.
14
 */
15
final class CompositeNotFoundException extends Exception implements NotFoundExceptionInterface
16
{
17
    /**
18
     * @param array $exceptions Container exceptions in [throwable, container] format.
19
     *
20
     * @psalm-param list<array{\Throwable,ContainerInterface}> $exceptions
21
     */
22 8
    public function __construct(array $exceptions)
23
    {
24 8
        $message = '';
25
26 8
        foreach ($exceptions as $i => [$exception, $container]) {
27 6
            $containerClass = $container::class;
28 6
            $containerId = spl_object_id($container);
29 6
            $number = $i + 1;
30
31 6
            $message .= "\n    $number. Container $containerClass #$containerId: {$exception->getMessage()}";
32
        }
33
34 8
        parent::__construct(sprintf('No definition or class found or resolvable in composite container:%s', $message));
35
    }
36
}
37