<?php

namespace app\foreignone\files;

enum ArchiveType: string
{
    case WilliamFriedman = 'wff';
    case MercureDeFrance = 'mdf';
    case Baconiana = 'baconiana';

    public function getSphinxIndex(): string {
        return match ($this) {
            self::WilliamFriedman => 'wff_collection',
            self::MercureDeFrance => 'mdf_archive',
            self::Baconiana => 'baconiana_archive',
        };
    }

    public function getMySQLData(): array {
        return match ($this) {
            self::WilliamFriedman => ['wff_texts', 'wff_id'],
            self::MercureDeFrance => ['mdf_texts', 'mdf_id'],
            self::Baconiana => ['baconiana_texts', 'bcn_id'],
        };
    }

    public function getItemsByIdGetter(): callable {
        return match ($this) {
            self::WilliamFriedman => WFFArchiveFile::getItemsById(...),
            self::MercureDeFrance => MDFIssue::getIssuesById(...),
            self::Baconiana => BaconianaIssue::getIssuesById(...),
        };
    }

    public function getFolderGetter(): callable {
        return match ($this) {
            ArchiveType::WilliamFriedman => WFFArchiveFile::getFolder(...),
            ArchiveType::Baconiana => BaconianaIssue::getFolder(...),
        };
    }

    public function getListGetter(): callable {
        return match ($this) {
            self::WilliamFriedman => WFFArchiveFile::getList(...),
            self::MercureDeFrance => MDFIssue::getAll(...),
            self::Baconiana => BaconianaIssue::getList(...),
        };
    }
}
