cursor = $cursor; $this->processed = $processed; $this->finished = $finished; $this->failed = $failed; $this->error = $error; } /** * Work happened and more remains. * * @since 1.14.0 * * @param int $cursor Id of the last item fully committed. * @param int $processed Items handled in this batch. */ public static function progress( int $cursor, int $processed ): self { return new self( $cursor, $processed, false, false, '' ); } /** * Nothing left for this stage to do. * * @since 1.14.0 * * @param int $processed Items handled in this batch. */ public static function finished( int $processed ): self { return new self( 0, $processed, true, false, '' ); } /** * This attempt failed; the runner decides whether to retry. * * @since 1.14.0 * * @param string $error Human-readable reason. */ public static function failed( string $error ): self { return new self( 0, 0, false, true, $error ); } /** * @since 1.14.0 */ public function cursor(): int { return $this->cursor; } /** * @since 1.14.0 */ public function processed(): int { return $this->processed; } /** * @since 1.14.0 */ public function is_finished(): bool { return $this->finished; } /** * @since 1.14.0 */ public function is_failed(): bool { return $this->failed; } /** * @since 1.14.0 */ public function error(): string { return $this->error; } }