$data Component payload. * @param list> $fields Field descriptors. * @param array $summary Running summary. * @param list $notices Notices. */ public function __construct( private readonly string $name, private readonly string $label, private readonly string $component, private readonly bool $can_go_back, private readonly bool $can_go_next, private readonly string $next_label, private readonly array $data = [], private readonly array $fields = [], private readonly array $summary = [], private readonly array $notices = [], ) {} /** * Step name. */ public function name(): string { return $this->name; } /** * Label. */ public function label(): string { return $this->label; } /** * Component key. */ public function component(): string { return $this->component; } /** * Can go back. */ public function can_go_back(): bool { return $this->can_go_back; } /** * Can go next. */ public function can_go_next(): bool { return $this->can_go_next; } /** * Next button label. */ public function next_label(): string { return $this->next_label; } /** * Component data. * * @return array */ public function data(): array { return $this->data; } /** * Fields. * * @return list> */ public function fields(): array { return $this->fields; } /** * Summary. * * @return array */ public function summary(): array { return $this->summary; } /** * Notices. * * @return list */ public function notices(): array { return $this->notices; } /** * Clone with merged component data. * * @param array $extra Extra payload keys. */ public function with_data( array $extra ): self { return new self( $this->name, $this->label, $this->component, $this->can_go_back, $this->can_go_next, $this->next_label, array_merge( $this->data, $extra ), $this->fields, $this->summary, $this->notices, ); } /** * Serialise for JSON responses. * * @return array */ public function to_array(): array { return [ 'name' => $this->name, 'label' => $this->label, 'component' => $this->component, 'canGoBack' => $this->can_go_back, 'canGoNext' => $this->can_go_next, 'nextLabel' => $this->next_label, 'data' => $this->data, 'fields' => $this->fields, 'summary' => $this->summary, 'notices' => $this->notices, ]; } }