[ Index ]

MailPress 544

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-includes/Swiftmailer/classes/Swift/ByteStream/ -> TemporaryFileByteStream.php (source)

   1  <?php
   2  
   3  /*
   4  * This file is part of SwiftMailer.
   5  * (c) 2004-2009 Chris Corbyn
   6  *
   7  * For the full copyright and license information, please view the LICENSE
   8  * file that was distributed with this source code.
   9  */
  10  
  11  /**
  12   * @author Romain-Geissler
  13   */
  14  class Swift_ByteStream_TemporaryFileByteStream extends Swift_ByteStream_FileByteStream
  15  {
  16      public function __construct()
  17      {
  18          $filePath = tempnam(sys_get_temp_dir(), 'FileByteStream');
  19  
  20          if ($filePath === false) {
  21              throw new Swift_IoException('Failed to retrieve temporary file name.');
  22          }
  23  
  24          parent::__construct($filePath, true);
  25      }
  26  
  27      public function getContent()
  28      {
  29          if (($content = file_get_contents($this->getPath())) === false) {
  30              throw new Swift_IoException('Failed to get temporary file content.');
  31          }
  32  
  33          return $content;
  34      }
  35  
  36      public function __destruct()
  37      {
  38          if (file_exists($this->getPath())) {
  39              @unlink($this->getPath());
  40          }
  41      }
  42  }


Generated: Thu Apr 28 18:38:52 2016 Cross-referenced by PHPXref 0.7.1