<?php

declare(strict_types=1);

namespace App\Framework\DI\Exceptions;

use App\Framework\Exception\FrameworkException;

final class CyclicDependencyException extends FrameworkException
{
    public function __construct(
        array $dependencyChain,
        string $class,
        int $code = 0,
        ?\Throwable $previous = null
    ) {
        parent::__construct(
            message: 'Zyklische Abhängigkeit entdeckt: ' . implode(' -> ', $dependencyChain) . " -> $class",
            code: $code,
            previous: $previous,
            context: [
                'dependencyChain' => $dependencyChain,
                'class' => $class
            ]
        );
    }
}
