$args * @param NextStep[] $nextSteps * @param Filter[] $filters */ public function __construct( string $id, string $type, string $key, array $args, array $nextSteps, array $filters = [] ) { $this->id = $id; $this->type = $type; $this->key = $key; $this->args = $args; $this->nextSteps = $nextSteps; $this->filters = $filters; } public function getId(): string { return $this->id; } public function getType(): string { return $this->type; } public function getKey(): string { return $this->key; } /** @return NextStep[] */ public function getNextSteps(): array { return $this->nextSteps; } /** @param NextStep[] $nextSteps */ public function setNextSteps(array $nextSteps): void { $this->nextSteps = $nextSteps; } public function getArgs(): array { return $this->args; } /** @return Filter[] */ public function getFilters(): array { return $this->filters; } public function toArray(): array { return [ 'id' => $this->id, 'type' => $this->type, 'key' => $this->key, 'args' => $this->args, 'next_steps' => array_map(function (NextStep $nextStep) { return $nextStep->toArray(); }, $this->nextSteps), 'filters' => array_map(function (Filter $filter) { return $filter->toArray(); }, $this->filters), ]; } public static function fromArray(array $data): self { return new self( $data['id'], $data['type'], $data['key'], $data['args'], array_map(function (array $nextStep) { return NextStep::fromArray($nextStep); }, $data['next_steps']), array_map(function (array $filter) { return Filter::fromArray($filter); }, $data['filters'] ?? []) ); } }