Passed
Push — master ( 3b8ce4...b46cbf )
by Alexander
03:01
created

CompositeNotFoundException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
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 18
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
     */
19 7
    public function __construct(array $exceptions)
20
    {
21 7
        $message = '';
22
23 7
        foreach ($exceptions as $i => [$exception, $container]) {
24 5
            $containerClass = get_class($container);
25 5
            $containerId = spl_object_id($container);
26 5
            $number = (int)$i + 1;
27
28 5
            $message .= "\n    $number. Container $containerClass #$containerId: {$exception->getMessage()}";
29
        }
30
31 7
        parent::__construct(sprintf('No definition or class found or resolvable in composite container:%s', $message));
32 7
    }
33
}
34