| 1 | <?php |
||
| 14 | class Swift_ByteStream_TemporaryFileByteStream extends Swift_ByteStream_FileByteStream |
||
|
|
|||
| 15 | { |
||
| 16 | 8 | public function __construct() |
|
| 17 | { |
||
| 18 | 8 | $filePath = tempnam(sys_get_temp_dir(), 'FileByteStream'); |
|
| 19 | 8 | if ($filePath === false) { |
|
| 20 | throw new Swift_IoException('Failed to retrieve temporary file name.'); |
||
| 21 | } |
||
| 22 | |||
| 23 | 8 | parent::__construct($filePath, true); |
|
| 24 | 8 | } |
|
| 25 | |||
| 26 | 8 | public function getContent() |
|
| 27 | { |
||
| 28 | 8 | $content = file_get_contents($this->getPath()); |
|
| 29 | 8 | if ($content === false) { |
|
| 30 | throw new Swift_IoException('Failed to get temporary file content.'); |
||
| 31 | } |
||
| 32 | |||
| 33 | 8 | return $content; |
|
| 34 | } |
||
| 35 | |||
| 36 | 8 | public function __destruct() |
|
| 42 | } |
||
| 43 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.