Test Failed
Push — fix-exception-messages ( 28ab20 )
by Dmitriy
12:27
created

BuildingException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Di;
6
7
use Exception;
8
use Psr\Container\ContainerExceptionInterface;
9
use Psr\Container\NotFoundExceptionInterface;
10
use Throwable;
11
12
/**
13
 * `NotFoundException` is thrown when no definition or class was found in the container for a given ID.
14
 */
15
final class BuildingException extends Exception implements ContainerExceptionInterface
16
{
17
    /**
18
     * @param string $id ID of the definition or name of the class that was not found.
19
     * @param string[] $buildStack Stack of IDs of services requested definition or class that was not found.
20
     */
21
    public function __construct(
22
        string $id,
23
        string $error,
24
        array $buildStack = [],
25
        Throwable $previous = null,
26
    ) {
27
        $message = sprintf('An error "%s" occurred while building "%s"', $error, $id);
28
29
        if ($buildStack !== []) {
30
            $message .= '"' . implode('" -> "', $buildStack) . '"';
31
        }
32
33
        $message .= '.';
34
35
        parent::__construct($message, 0, $previous);
36
    }
37
}
38