0 ) ); } /** * Create exception for text too long * * @since 1.0.0 * @param int $length Current text length. * @param int $max_length Maximum allowed length. * @return self. */ public static function text_too_long( int $length, int $max_length ): self { return new self( 'Text exceeds maximum allowed length', 400, null, array( 'text_length' => $length, 'max_length' => $max_length, ) ); } /** * Create exception for unsupported content type * * @since 1.0.0 * @param string $content_type Unsupported content type. * @param array $supported_types Supported content types. * @return self. */ public static function unsupported_content_type( string $content_type, array $supported_types ): self { return new self( 'Unsupported content type for text processing', 400, null, array( 'content_type' => $content_type, 'supported_types' => $supported_types, ) ); } /** * Create exception for invalid encoding * * @since 1.0.0 * @param string $encoding Invalid encoding. * @return self. */ public static function invalid_encoding( string $encoding ): self { return new self( 'Invalid text encoding detected', 400, null, array( 'encoding' => $encoding ) ); } /** * Create exception for cleaning failure * * @since 1.0.0 * @param string $error_message Cleaning error message. * @return self. */ public static function cleaning_failure( string $error_message ): self { return new self( 'Text cleaning process failed', 500, null, array( 'cleaning_error' => $error_message ) ); } }