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;
    }
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;
    }
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 ; }
Reads the contents of the specified file and returns it as a string.

@param string $filename the name of the file that is to be read.

@throws PhpCapException if an error occurs while trying to read the file.

@return string the contents of the specified file.
Reads the contents of the specified file and returns it as a string .