<?php

declare(strict_types=1);

namespace App\Framework\DI\Attributes;

use Attribute;

/**
 * Marks a class as the default implementation for an interface
 *
 * When applied to a class, this attribute enables automatic registration
 * in the DI container with the specified interface (or auto-detected interface).
 *
 * Usage:
 * - Explicit interface: #[DefaultImplementation(UserRepository::class)]
 * - Auto-detect: #[DefaultImplementation] (uses first implemented interface)
 *
 * Validation:
 * - If interface is specified: class must implement that interface
 * - If interface is not specified: class must implement at least one interface
 */
#[Attribute(Attribute::TARGET_CLASS)]
final readonly class DefaultImplementation
{
    /**
     * @param class-string|null $interface Optional interface to bind to. If null, auto-detect first interface.
     */
    public function __construct(
        public ?string $interface = null
    ) {}
}
