public static function fileToString($filename)
    {
        $errorHandler = static::getErrorHandler();
        
        if (!file_exists($filename)) {
            $errorHandler->throwException(
                'The input file "'.$filename.'" could not be found.',
                ErrorHandlerInterface::INPUT_FILE_NOT_FOUND
            );
        } elseif (!is_readable($filename)) {
            $errorHandler->throwException(
                'The input file "'.$filename.'" was unreadable.',
                ErrorHandlerInterface::INPUT_FILE_UNREADABLE
            );
        } // @codeCoverageIgnore
        
        $contents = file_get_contents($filename);

        if ($contents === false) {
            $error = error_get_last();
            $errorMessage = null;
            if ($error != null && array_key_exists('message', $error)) {
                $errorMessage = $error['message'];
            }
            
            if (isset($errorMessage)) {
                $errorHandler->throwException(
                    'An error occurred in input file "'.$filename.'": '.$errorMessage,
                    ErrorHandlerInterface::INPUT_FILE_ERROR
                );
            } else { // @codeCoverageIgnore
                $errorHandler->throwException(
                    'An error occurred in input file "'.$filename.'"',
                    ErrorHandlerInterface::INPUT_FILE_ERROR
                );
            } // @codeCoverageIgnore
        } // @codeCoverageIgnore
        
        return $contents;
    }