presseportale/app/Services/Import/ImportContext.php
Kevin Adametz 5b8bdf4182
Some checks are pending
linter / quality (push) Waiting to run
tests / ci (push) Waiting to run
12-05-2026 Frontend dev
2026-05-12 18:32:33 +02:00

38 lines
1,010 B
PHP

<?php
namespace App\Services\Import;
use App\Enums\Portal;
/**
* Hält den Kontext für einen Import-Lauf.
*/
final class ImportContext
{
public readonly ?Portal $portalEnum;
public readonly ?string $connection;
public function __construct(
public readonly string $portal, // 'presseecho' | 'businessportal24' | 'all'
public readonly bool $dryRun = false,
public readonly bool $force = false,
) {
if ($portal === 'all') {
$this->portalEnum = null;
$this->connection = null;
} else {
$this->portalEnum = Portal::from($portal);
$this->connection = match ($portal) {
'presseecho' => 'mysql_presseecho',
'businessportal24' => 'mysql_businessportal',
default => throw new \InvalidArgumentException("Unbekanntes Portal: {$portal}"),
};
}
}
public function legacyPortalValue(): string
{
return $this->portal;
}
}