Test Failed
Push — main ( ace48b...917e6f )
by Chema
23:03 queued 20:04
created

CircularDependencyException   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

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

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
    public static function create(array $dependencyChain): self
16
    {
17
        $chain = implode(' -> ', $dependencyChain);
18
        $message = <<<TXT
19
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
TXT;
24
        return new self($message);
25
    }
26
}
27