Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function close()
 {
     if ($this->stream !== NULL) {
         $this->hash = hash_final($this->md5);
     }
     parent::close();
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function close()
 {
     if ($this->buffer !== NULL) {
         fclose($this->buffer);
         $this->buffer = NULL;
     }
     parent::close();
 }
Exemplo n.º 3
0
 /**
  * Limit the given input stream to the given number of bytes.
  * 
  * @param StreamInterface $stream
  * @param int $limit
  * 
  * @throws \InvalidArgumentException When the given limit is negative.
  */
 public function __construct(StreamInterface $stream, $limit)
 {
     parent::__construct($stream);
     $this->limit = (int) $limit;
     if ($this->limit < 0) {
         throw new \InvalidArgumentException(sprintf('Limit must not be less than 0, given: %s', $this->limit));
     }
 }
Exemplo n.º 4
0
 /**
  * Decompress data as it is being read from the given input stream.
  * 
  * @param StreamInterface $stream
  * @param int $encoding
  * 
  * @throws \RuntimeException When decompression is not supported by the installed PHP version.
  * @throws \InvalidArgumentException When an invalid compression encoding is specified.
  */
 public function __construct(StreamInterface $stream, $encoding = self::DEFLATE)
 {
     if (!function_exists('inflate_init')) {
         throw new \RuntimeException('Stream decompression requires PHP 7');
     }
     parent::__construct($stream);
     switch ($encoding) {
         case self::RAW:
         case self::DEFLATE:
         case self::GZIP:
             // OK
             break;
         default:
             throw new \InvalidArgumentException(sprintf('Invalid decompression ecncoding specified: %s', $encoding));
     }
     $this->context = $this->invokeWithErrorHandler('inflate_init', $encoding);
 }
Exemplo n.º 5
0
 /**
  * Compress data as it being read from the given input stream.
  * 
  * @param StreamInterface $stream
  * @param int $encoding
  * @param int $level
  * @param int $window
  * 
  * @throws \RuntimeException When compression is not supported by the installed PHP version.
  * @throws \InvalidArgumentException When compression level / window are invalid.
  */
 public function __construct(StreamInterface $stream, $encoding = ZLIB_ENCODING_DEFLATE, $level = 1, $window = 32768)
 {
     if (!function_exists('deflate_init')) {
         throw new \RuntimeException('Stream compression requires PHP 7');
     }
     parent::__construct($stream);
     switch ($encoding) {
         case self::RAW:
         case self::DEFLATE:
         case self::GZIP:
             // OK
             break;
         default:
             throw new \InvalidArgumentException(sprintf('Invalid compression ecncoding specified: %s', $encoding));
     }
     $level = (int) $level;
     if ($level < 1 || $level > 9) {
         throw new \InvalidArgumentException(sprintf('Compression level must be between 1 and 9, given %s', $level));
     }
     $this->context = $this->invokeWithErrorHandler('deflate_init', $encoding, ['level' => $level]);
     $this->window = (int) $window;
 }