<?php

declare(strict_types=1);

namespace App\Framework\Http;

final class MimeTypeAnalyzer
{
    public static function isImage(MimeType $mimeType): bool
    {
        return match ($mimeType) {
            MimeType::IMAGE_JPEG,
            MimeType::IMAGE_PNG,
            MimeType::IMAGE_GIF,
            MimeType::IMAGE_SVG,
            MimeType::IMAGE_WEBP,
            MimeType::IMAGE_BMP,
            MimeType::IMAGE_TIFF,
            MimeType::IMAGE_ICO => true,
            default => false,
        };
    }

    public static function isDocument(MimeType $mimeType): bool
    {
        return match ($mimeType) {
            MimeType::APPLICATION_PDF,
            MimeType::APPLICATION_MSWORD,
            MimeType::APPLICATION_MSWORD_X,
            MimeType::APPLICATION_EXCEL,
            MimeType::APPLICATION_EXCEL_X,
            MimeType::APPLICATION_POWERPOINT,
            MimeType::APPLICATION_POWERPOINT_X => true,
            default => false,
        };
    }

    public static function isText(MimeType $mimeType): bool
    {
        return match ($mimeType) {
            MimeType::TEXT_PLAIN,
            MimeType::TEXT_HTML,
            MimeType::TEXT_CSS,
            MimeType::TEXT_CSV,
            MimeType::TEXT_JAVASCRIPT,
            MimeType::TEXT_XML,
            MimeType::TEXT_MARKDOWN => true,
            default => false,
        };
    }

    public static function isAudio(MimeType $mimeType): bool
    {
        return match ($mimeType) {
            MimeType::AUDIO_MPEG,
            MimeType::AUDIO_WAV,
            MimeType::AUDIO_OGG,
            MimeType::AUDIO_WEBM,
            MimeType::AUDIO_AAC,
            MimeType::AUDIO_FLAC => true,
            default => false,
        };
    }

    public static function isVideo(MimeType $mimeType): bool
    {
        return match ($mimeType) {
            MimeType::VIDEO_MP4,
            MimeType::VIDEO_WEBM,
            MimeType::VIDEO_OGG,
            MimeType::VIDEO_AVI,
            MimeType::VIDEO_QUICKTIME => true,
            default => false,
        };
    }

    public static function isCompressed(MimeType $mimeType): bool
    {
        return match ($mimeType) {
            MimeType::APPLICATION_ZIP,
            MimeType::APPLICATION_GZIP,
            MimeType::APPLICATION_RAR,
            MimeType::APPLICATION_7Z => true,
            default => false,
        };
    }

    public static function isStreamable(MimeType $mimeType): bool
    {
        return self::isAudio($mimeType) || self::isVideo($mimeType);
    }

    public static function isBinary(MimeType $mimeType): bool
    {
        return ! self::isText($mimeType);
    }
}
