57 lines
1.6 KiB
PHP
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;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|