CircularReferenceException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 2
b 0
f 0
dl 0
loc 29
ccs 9
cts 9
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getServiceId() 0 3 1
A __construct() 0 6 1
A getPath() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of DivineNii opensource projects.
7
 *
8
 * PHP version 7.4 and above required
9
 *
10
 * @author    Divine Niiquaye Ibok <[email protected]>
11
 * @copyright 2021 DivineNii (https://divinenii.com/)
12
 * @license   https://opensource.org/licenses/BSD-3-Clause License
13
 *
14
 * For the full copyright and license information, please view the LICENSE
15
 * file that was distributed with this source code.
16
 */
17
18
namespace Rade\DI\Exceptions;
19
20
use Psr\Container\ContainerExceptionInterface;
21
22
class CircularReferenceException extends \InvalidArgumentException implements ContainerExceptionInterface
23
{
24
    private string $serviceId;
25
26
    /** @var array<int,string> */
27
    private array $path;
28
29
    /**
30
     * @param array<int,string> $path
31
     */
32 9
    public function __construct(string $serviceId, array $path, \Throwable $previous = null)
33
    {
34 9
        parent::__construct(\sprintf('Circular reference detected for service "%s", path: "%s".', $serviceId, \implode(' -> ', $path)), 0, $previous);
35
36 9
        $this->serviceId = $serviceId;
37 9
        $this->path = $path;
38 9
    }
39
40 1
    public function getServiceId(): string
41
    {
42 1
        return $this->serviceId;
43
    }
44
45
    /**
46
     * @return array<int,string>
47
     */
48 1
    public function getPath(): array
49
    {
50 1
        return $this->path;
51
    }
52
}
53