Files
citrus-cms/app/Services/RegisterCreator/DocumentProcessors/DocumentProcessorFactory.php
T
2026-04-28 21:14:25 +03:00

57 lines
1.6 KiB
PHP

<?php
namespace App\Services\RegisterCreator\DocumentProcessors;
use Exception;
class DocumentProcessorFactory
{
/**
* Create document processor instance based on type
*/
public static function make(string $type, ?array $document = null): AbstractDocumentProcessor
{
// Check if this is a dynamic document
if ($type === 'dynamic' || ($document && isset($document['is_dynamic']) && $document['is_dynamic'])) {
return new DynamicMappingProcessor();
}
return match($type) {
'qa' => new QaDocumentProcessor(),
'wdb' => new WdbDocumentProcessor(),
'wps_naks_technology' => new WpsNaksTechnologyProcessor(),
'naks_consumables_certificate' => new NaksConsumablesCertificateProcessor(),
'naks_consumables_inspection_test_report' => new NaksConsumablesInspectionProcessor(),
'drawings' => new DrawingsProcessor(),
'materials' => new MaterialsProcessor(),
'incoming_control_materials' => new IncomingControlProcessor(),
'template' => new TemplateProcessor(),
'prikaz' => new PrikazProcessor(),
'document-procedure' => new DocumentProcedureProcessor(),
'dynamic' => new DynamicMappingProcessor(),
default => new GenericDocumentProcessor(),
};
}
/**
* Check if processor exists for given type
*/
public static function exists(string $type): bool
{
try {
self::make($type);
return true;
} catch (\Throwable $th) {
return false;
}
}
}