32 lines
1015 B
PHP
32 lines
1015 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Archive\Async1;
|
|
|
|
use App\Framework\Async1\AsyncDiscovery;
|
|
use App\Framework\Async1\PcntlTaskProcessor;
|
|
use App\Framework\Async1\TaskProcessorFactory;
|
|
use App\Framework\Core\AttributeMapper;
|
|
use App\Framework\Core\Discovery;
|
|
|
|
final class DiscoveryFactory
|
|
{
|
|
/**
|
|
* Erstellt eine Discovery-Instanz mit optionaler asynchroner Verarbeitung
|
|
*
|
|
* @param bool $useAsync Ob asynchrone Verarbeitung genutzt werden soll
|
|
* @param string|null $srcDir Quellverzeichnis für automatisches Auffinden von Mappern
|
|
* @param AttributeMapper ...$mappers AttributeMapper-Instanzen
|
|
* @return Discovery
|
|
*/
|
|
public static function create(bool $useAsync = true, ?string $srcDir = null, AttributeMapper ...$mappers): Discovery
|
|
{
|
|
if ($useAsync && PcntlTaskProcessor::isAvailable()) {
|
|
return new AsyncDiscovery($srcDir, TaskProcessorFactory::create(), ...$mappers);
|
|
}
|
|
|
|
return new Discovery($srcDir, ...$mappers);
|
|
}
|
|
|
|
}
|