$steps */ private function __construct( private ?int $id, private int $workTypeId, private CatalogName $name, private bool $active, private array $steps, ) {} /** * @param list $steps * * @throws WorkflowTemplateNeedsSteps */ public static function create(int $workTypeId, CatalogName $name, array $steps): self { self::ensureSteps($steps); return new self(null, $workTypeId, $name, true, $steps); } /** * @param list $steps */ public static function reconstitute(int $id, int $workTypeId, CatalogName $name, bool $active, array $steps): self { return new self($id, $workTypeId, $name, $active, $steps); } public function id(): ?int { return $this->id; } public function workTypeId(): int { return $this->workTypeId; } public function name(): CatalogName { return $this->name; } public function isActive(): bool { return $this->active; } /** * @return list */ public function steps(): array { return $this->steps; } /** * Changes the name, the work type and the steps at once, as the template form saves them. * * @param list $steps * * @throws WorkflowTemplateNeedsSteps */ public function change(int $workTypeId, CatalogName $name, array $steps): void { self::ensureSteps($steps); $this->workTypeId = $workTypeId; $this->name = $name; $this->steps = $steps; } public function activate(): void { $this->active = true; } public function deactivate(): void { $this->active = false; } /** * @param list $steps */ private static function ensureSteps(array $steps): void { if ($steps === []) { throw new WorkflowTemplateNeedsSteps; } } }