taskId = $taskId; $this->status = $status; $this->createdAt = $createdAt; $this->lastUpdatedAt = $lastUpdatedAt; $this->ttl = $ttl; $this->statusMessage = $statusMessage; $this->pollInterval = $pollInterval; } /** * Creates an instance from an array. * * @param array{ * taskId: string, * status: 'working'|'input_required'|'completed'|'failed'|'cancelled', * statusMessage?: string|null, * createdAt: string, * lastUpdatedAt: string, * ttl: int|null, * pollInterval?: int|null * } $data * @phpstan-param array $data * @return self */ public static function fromArray(array $data): self { self::assertRequired($data, ['taskId', 'status', 'createdAt', 'lastUpdatedAt', 'ttl']); /** @var 'working'|'input_required'|'completed'|'failed'|'cancelled' $status */ $status = self::asString($data['status']); return new self( self::asString($data['taskId']), $status, self::asString($data['createdAt']), self::asString($data['lastUpdatedAt']), self::asInt($data['ttl']), self::asStringOrNull($data['statusMessage'] ?? null), self::asIntOrNull($data['pollInterval'] ?? null) ); } /** * Converts the instance to an array. * * @return array */ public function toArray(): array { $result = []; $result['taskId'] = $this->taskId; $result['status'] = $this->status; if ($this->statusMessage !== null) { $result['statusMessage'] = $this->statusMessage; } $result['createdAt'] = $this->createdAt; $result['lastUpdatedAt'] = $this->lastUpdatedAt; if ($this->ttl !== null) { $result['ttl'] = $this->ttl; } if ($this->pollInterval !== null) { $result['pollInterval'] = $this->pollInterval; } return $result; } /** * @return string */ public function getTaskId(): string { return $this->taskId; } /** * @return 'working'|'input_required'|'completed'|'failed'|'cancelled' */ public function getStatus(): string { return $this->status; } /** * @return string|null */ public function getStatusMessage(): ?string { return $this->statusMessage; } /** * @return string */ public function getCreatedAt(): string { return $this->createdAt; } /** * @return string */ public function getLastUpdatedAt(): string { return $this->lastUpdatedAt; } /** * @return int|null */ public function getTtl(): ?int { return $this->ttl; } /** * @return int|null */ public function getPollInterval(): ?int { return $this->pollInterval; } }