radfusion/app/Services/Report/Export/Exporters.php

27 lines
861 B
PHP

<?php
namespace App\Services\Report\Export;
use App\Domain\Report\ExportFormat;
use App\Models\Study;
use App\Models\StudyReport;
use App\Services\Report\Export\Formats\HtmlExport;
use App\Services\Report\Export\Formats\PdfExport;
use App\Services\Report\Export\Formats\Word2003Export;
use App\Services\Report\Export\Formats\Word2007Export;
final readonly class Exporters
{
public static function make(Study $study, StudyReport $report, ExportFormat $format)
{
$exporter = match ($format) {
ExportFormat::Html => new HtmlExport($study, $report),
ExportFormat::Word2003 => new Word2003Export($study, $report),
ExportFormat::Word2007 => new Word2007Export($study, $report),
ExportFormat::Pdf => new PdfExport($study, $report),
};
return $exporter->make($study, $report);
}
}