$errors Messages keyed by field. * @return WP_Error */ public static function invalid( array $errors ): WP_Error { return new WP_Error( 'hostkhata_invalid_input', __( 'Please check the highlighted fields.', 'hostkhata' ), array( 'status' => 400, 'errors' => $errors, ) ); } /** * The record does not exist. * * @since 0.1.0 * * @param string $message Message. * @return WP_Error */ public static function not_found( string $message ): WP_Error { return new WP_Error( 'hostkhata_not_found', $message, array( 'status' => 404 ) ); } /** * A value clashes with an existing record. * * @since 0.1.0 * * @param string $field Field name. * @param string $message Message. * @return WP_Error */ public static function conflict( string $field, string $message ): WP_Error { return new WP_Error( 'hostkhata_conflict', $message, array( 'status' => 409, 'errors' => array( $field => $message ), ) ); } /** * The action is not allowed in the current state. * * @since 0.1.0 * * @param string $code Error code. * @param string $message Message. * @return WP_Error */ public static function state( string $code, string $message ): WP_Error { return new WP_Error( $code, $message, array( 'status' => 409 ) ); } /** * The record could not be saved. * * @since 0.1.0 * * @param string $message Message. * @return WP_Error */ public static function failed( string $message ): WP_Error { return new WP_Error( 'hostkhata_save_failed', $message, array( 'status' => 500 ) ); } }