src/TempFile.php
public static function fromFile($path) {

        if(!is_file($path) || !is_readable($path)) {

            throw new TempFileException(sprintf('File %s does not exist or is not readable.', $path));
        }

        $tempFile = new static();
        $tempFile->closeFileHandle();

        if(!copy($path, $tempFile->filePath)) {

            throw new TempFileException(sprintf('Could not read in file %s.', $path));
        }

        $tempFile->openFileHandle('r+');

        return $tempFile;
    }
public static function fromFile($path) {

        if(!is_file($path) || !is_readable($path)) {

            throw new TempFileException(sprintf('File %s does not exist or is not readable.', $path));
        }

        $tempFile = new static();
        $tempFile->closeFileHandle();

        if(!copy($path, $tempFile->filePath)) {

            throw new TempFileException(sprintf('Could not read in file %s.', $path));
        }

        $tempFile->openFileHandle('r+');

        return $tempFile;
    }
public static function fromFile ( $ path ) { if ( ! is_file ( $ path ) || ! is_readable ( $ path ) ) { throw new TempFileException ( sprintf ( 'File %s does not exist or is not readable.' , $ path ) ) ; } $ tempFile = new static ( ) ; $ tempFile -> closeFileHandle ( ) ; if ( ! copy ( $ path , $ tempFile -> filePath ) ) { throw new TempFileException ( sprintf ( 'Could not read in file %s.' , $ path ) ) ; } $ tempFile -> openFileHandle ( 'r+' ) ; return $ tempFile ; }
Returns a TempFile object representing a copy of an existing file.
The file pointer is set to the beginning to the file.

@param string $path

@return TempFile
@throws TempFileException
Returns a TempFile object representing a copy of an existing file . The file pointer is set to the beginning to the file .