CircularDependencyException   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
eloc 6
c 1
b 0
f 1
dl 0
loc 15
ccs 6
cts 6
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Container\Exception;
6
7
use Psr\Container\ContainerExceptionInterface;
8
use RuntimeException;
9
10
final class CircularDependencyException extends RuntimeException implements ContainerExceptionInterface
11
{
12
    /**
13
     * @param list<string> $dependencyChain
14
     */
15 2
    public static function create(array $dependencyChain): self
16
    {
17 2
        $chain = implode(' -> ', $dependencyChain);
18 2
        $message = <<<TXT
19 2
Circular dependency detected: {$chain}
20
21
This happens when classes depend on each other in a loop.
22
Consider using setter injection or the factory pattern to break the cycle.
23 2
TXT;
24 2
        return new self($message);
25
    }
26
}
27