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

27 lines
705 B
PHP

<?php
namespace App\Services\Report\Export;
use App\Models\Study;
use App\Models\StudyReport;
use Illuminate\Support\Str;
abstract class ExportDocumentBase implements IExportDocument
{
public function __construct(protected readonly Study $study, protected readonly StudyReport $report) {}
public function make(Study $study, StudyReport $report): string
{
return $this->handle();
}
abstract protected function handle(): string;
abstract protected function getExtension(): string;
protected function filename(?string $ext = null): string
{
return sprintf('exp_%s.%s', Str::slug($this->report->accession_number), $ext ?? $this->getExtension());
}
}