From 41a4a08c927c0200c97b500b1378ffa01851506f Mon Sep 17 00:00:00 2001 From: Zaahid Bateson Date: Mon, 16 Jul 2018 20:48:47 -0500 Subject: [PATCH] Remove no longer used abstract class --- src/AbstractMimeTransferStreamDecorator.php | 176 -------------------- 1 file changed, 176 deletions(-) delete mode 100644 src/AbstractMimeTransferStreamDecorator.php diff --git a/src/AbstractMimeTransferStreamDecorator.php b/src/AbstractMimeTransferStreamDecorator.php deleted file mode 100644 index 03728f2..0000000 --- a/src/AbstractMimeTransferStreamDecorator.php +++ /dev/null @@ -1,176 +0,0 @@ -getSizeWithSeekBack(true); - } - - /** - * Can optionally seek back to the current position. - * - * Useful when called from seek with SEEK_END, there's no need to seek back - * to the current position when called within seek. - * - * @param type $seekBack - */ - private function getSizeWithSeekBack($seekBack) { - $pos = $this->position; - $this->rewind(); - while (!$this->eof()) { - $this->read(1048576); - } - $length = $this->position; - if ($seekBack) { - $this->seek($pos); - } - return $length; - } - - /** - * Overridden to return the calculated position as bytes in the decoded - * stream. - * - * @return int - */ - public function tell() - { - return $this->position; - } - - /** - * Called before seeking to the specified offset, can be overridden by - * sub-classes to reset internal buffers, etc... - */ - protected function beforeSeek() { - // do nothing. - } - - /** - * Seeks to the given position. - * - * This operation basically reads and discards to the given position because - * the size of the underlying stream can't be calculated otherwise, and is - * an expensive operation. - * - * @param int $offset - * @param int $whence - */ - public function seek($offset, $whence = SEEK_SET) - { - $pos = $offset; - if ($whence === SEEK_CUR) { - $pos = $this->tell() + $offset; - } elseif ($whence === SEEK_END) { - $pos = $this->getSizeWithSeekBack(false) + $offset; - } - // $this->position may not report actual position, for instance if the - // underlying stream has been moved ahead. Checking if the requested - // position is the same as $pos before moving can cause problems when - // using a LimitStream for instance after the parent stream has been - // read from, etc... - $this->beforeSeek($pos); - $this->seekRaw(0); - $this->position = 0; - - // to avoid memory issues - while ($pos > 10240 && !$this->eof()) { - $this->read(10240); - $pos -= 10240; - } - $this->read($pos); - } - - /** - * Override to implement 'write' functionality and write bytes to the - * underlying stream. - * - * @param string $string - * @return int the number of bytes written - */ - public abstract function write($string); - - /** - * Override to implement read functionality, reading $length bytes from the - * underlying stream - * - * @param int $length - * @return string the string that was read - */ - public abstract function read($length); - - /** - * Flushes the underlying stream object if it's an instance of - * AbstractMimeTransferStreamDecorator. - */ - public function flush() - { - if ($this->stream && $this->stream instanceof AbstractMimeTransferStreamDecorator) { - $this->stream->flush(); - } - } - - /** - * Overridden to call flush() before detaching. - */ - public function detach() - { - $this->flush(); - $this->detachRaw(); - } - - /** - * Overridden to call flush() before detaching. - */ - public function close() - { - $this->flush(); - $this->closeRaw(); - } -}