protected function prepareChunk(StreamInterface $stream)
    {
        if (!$this->firstRun && is_null($this->shaved)) {
            // We're starting again after a flush
            $this->shaved = "";

            return true;
        } else if (is_null($this->shaved)) {
            $this->shaved = "";
        }

        $newChunk = $stream->getChunk();

        if ($newChunk !== false) {
            $this->chunk .= $newChunk;

            return true;
        } else {
            if (trim($this->chunk) !== "" && $this->chunk !== $this->lastChunk) {
                // Update anti-freeze protection chunk
                $this->lastChunk = $this->chunk;
                // Continue
                return true;
            }
        }

        return false;
    }
protected function prepareChunk(StreamInterface $stream)
    {
        if (!$this->firstRun && is_null($this->shaved)) {
            // We're starting again after a flush
            $this->shaved = "";

            return true;
        } else if (is_null($this->shaved)) {
            $this->shaved = "";
        }

        $newChunk = $stream->getChunk();

        if ($newChunk !== false) {
            $this->chunk .= $newChunk;

            return true;
        } else {
            if (trim($this->chunk) !== "" && $this->chunk !== $this->lastChunk) {
                // Update anti-freeze protection chunk
                $this->lastChunk = $this->chunk;
                // Continue
                return true;
            }
        }

        return false;
    }
protected function prepareChunk ( StreamInterface $ stream ) { if ( ! $ this -> firstRun && is_null ( $ this -> shaved ) ) { // We're starting again after a flush $ this -> shaved = "" ; return true ; } else if ( is_null ( $ this -> shaved ) ) { $ this -> shaved = "" ; } $ newChunk = $ stream -> getChunk ( ) ; if ( $ newChunk !== false ) { $ this -> chunk .= $ newChunk ; return true ; } else { if ( trim ( $ this -> chunk ) !== "" && $ this -> chunk !== $ this -> lastChunk ) { // Update anti-freeze protection chunk $ this -> lastChunk = $ this -> chunk ; // Continue return true ; } } return false ; }
The shave method must be able to request more data even though there isn't any more to fetch from the stream, this method wraps the getChunk call so that it returns true as long as there is XML data left
@param  StreamInterface $stream The stream to read from
@return bool Returns whether there is more XML data or not
The shave method must be able to request more data even though there isn t any more to fetch from the stream this method wraps the getChunk call so that it returns true as long as there is XML data left