success = $success; $this->content = $content; $this->reason = $reason; } /** * Builds a success result. * * @since 1.0.0 * * @param string $content Modified content. * * @return self */ public static function success( string $content ): self { return new self( true, $content, '' ); } /** * Builds a failure result. * * @since 1.0.0 * * @param string $reason One of the REASON_* class constants. * @param string $original_content Optional. Original content to echo back. * * @return self */ public static function failure( string $reason, string $original_content = '' ): self { return new self( false, $original_content, $reason ); } /** * Returns whether the operation modified content. * * @since 1.0.0 * * @return bool */ public function is_success(): bool { return $this->success; } /** * Returns the resulting content (modified on success, original on failure). * * @since 1.0.0 * * @return string */ public function get_content(): string { return $this->content; } /** * Returns the reason code on failure, or empty string on success. * * @since 1.0.0 * * @return string */ public function get_reason(): string { return $this->reason; } }