status = $status; $this->error_class = $error_class; $this->message = $message; $this->retry_at = $retry_at; } /** * Creates a DONE result. * * @since 1.5.0 * * @return self The result. */ public static function done(): self { return new self( self::DONE ); } /** * Creates a SKIPPED result. * * @since 1.5.0 * * @return self The result. */ public static function skipped(): self { return new self( self::SKIPPED ); } /** * Creates a REMOVED result. * * @since 1.5.0 * * @return self The result. */ public static function removed(): self { return new self( self::REMOVED ); } /** * Creates a DEFERRED result. * * @since 1.5.0 * * @param int $retry_at Unix time to retry. * @return self The result. */ public static function deferred( int $retry_at ): self { return new self( self::DEFERRED, null, '', $retry_at ); } /** * Creates a FAILED result. * * @since 1.5.0 * * @param string $error_class An Embedding_Client_Exception class constant. * @param string $message Failure message. * @return self The result. */ public static function failed( string $error_class, string $message ): self { return new self( self::FAILED, $error_class, $message ); } /** * Returns the status. * * @since 1.5.0 * * @return string One of the class constants. */ public function get_status(): string { return $this->status; } /** * Returns the failure class. * * @since 1.5.0 * * @return string|null The class, or null unless FAILED. */ public function get_error_class(): ?string { return $this->error_class; } /** * Returns the failure message. * * @since 1.5.0 * * @return string The message, or an empty string. */ public function get_message(): string { return $this->message; } /** * Returns the retry time. * * @since 1.5.0 * * @return int|null Unix time, or null unless DEFERRED. */ public function get_retry_at(): ?int { return $this->retry_at; } }