<?php

declare(strict_types=1);

namespace App\Framework\Http;

use App\Framework\Filesystem\ValueObjects\FilePath;

/**
 * Mock MIME type detector for testing
 *
 * Returns a predefined MIME type instead of detecting from file content
 */
final readonly class MockMimeTypeDetector implements MimeTypeDetector
{
    public function __construct(
        private MimeTypeInterface $mimeType
    ) {
    }

    /**
     * Create from MIME type string
     */
    public static function fromString(string $mimeTypeString): self
    {
        $mimeType = MimeType::tryFromString($mimeTypeString)
            ?? CustomMimeType::fromString($mimeTypeString);

        return new self($mimeType);
    }

    /**
     * Always returns the predefined MIME type, ignoring the file path
     */
    public function detect(FilePath $filePath): MimeTypeInterface
    {
        return $this->mimeType;
    }
}
