CircularDependencyDetected::formatStack()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AlecRabbit\Spinner\Container\Exception;
6
7
use ArrayObject;
8
use Throwable;
9
10
/**
11
 * @codeCoverageIgnore
12
 */
13
final class CircularDependencyDetected extends ContainerException
14
{
15
    public function __construct(ArrayObject $dependencyStack, ?Throwable $previous = null)
16
    {
17
        $message = 'Circular dependency detected!' . $this->formatStack($dependencyStack);
18
        parent::__construct($message, previous: $previous);
19
    }
20
21
    private function formatStack(ArrayObject $stack): string
22
    {
23
        /** @psalm-suppress MixedArgumentTypeCoercion */
24
        return PHP_EOL . implode(' ➜ ', $stack->getArrayCopy());
25
    }
26
}
27