Passed
Pull Request — master (#274)
by Alexander
02:37
created

CompositeNotFoundException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
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 19
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\NotFoundExceptionInterface;
9
10
/**
11
 * CompositeNotFoundException is thrown when no definition or class was found in the composite container for a given ID.
12
 * It contains all exceptions thrown by containers registered in the composite container.
13
 */
14
final class CompositeNotFoundException extends Exception implements NotFoundExceptionInterface
15
{
16
    /**
17
     * @param array $exceptions Exceptions of containers in [throwable, container] format.
18
     * @psalm-param array $exceptions
19
     */
20 7
    public function __construct(array $exceptions)
21
    {
22 7
        $message = '';
23
24 7
        foreach ($exceptions as $i => [$exception, $container]) {
25 5
            $containerClass = get_class($container);
26 5
            $containerId = spl_object_id($container);
27 5
            $number = $i + 1;
28
29 5
            $message .= "\n    $number. Container $containerClass #$containerId: {$exception->getMessage()}";
30
        }
31
32 7
        parent::__construct(sprintf('No definition or class found or resolvable in composite container:%s', $message));
33 7
    }
34
}
35