Swift_ByteStream_FileByteStream::__construct PHP Method

__construct() public method

Create a new FileByteStream for $path.
public __construct ( string $path, boolean $writable = false )
$path string
$writable boolean if true
    public function __construct($path, $writable = false)
    {
        if (empty($path)) {
            throw new Swift_IoException('The path cannot be empty');
        }
        $this->_path = $path;
        $this->_mode = $writable ? 'w+b' : 'rb';
        if (function_exists('get_magic_quotes_runtime') && @get_magic_quotes_runtime() == 1) {
            $this->_quotes = true;
        }
    }

Usage Example

 public function __construct()
 {
     $filePath = tempnam(sys_get_temp_dir(), 'FileByteStream');
     if ($filePath === false) {
         throw new Swift_IoException('Failed to retrieve temporary file name.');
     }
     parent::__construct($filePath, true);
 }