public function push($document)
    {
        $this->initialize();
        $this->currentPosition++;

        if (isset($this->metadata['count']) && $this->currentPosition > $this->metadata['count']) {
            throw new \OverflowException(
                sprintf('This writer was set up to write %d documents, got more.', $this->metadata['count'])
            );
        }

        fwrite($this->handle, ",\n");
        fwrite($this->handle, json_encode($document));

        if (isset($this->metadata['count']) && $this->currentPosition == $this->metadata['count']) {
            $this->finalize();
        }
    }
public function push($document)
    {
        $this->initialize();
        $this->currentPosition++;

        if (isset($this->metadata['count']) && $this->currentPosition > $this->metadata['count']) {
            throw new \OverflowException(
                sprintf('This writer was set up to write %d documents, got more.', $this->metadata['count'])
            );
        }

        fwrite($this->handle, ",\n");
        fwrite($this->handle, json_encode($document));

        if (isset($this->metadata['count']) && $this->currentPosition == $this->metadata['count']) {
            $this->finalize();
        }
    }
public function push ( $ document ) { $ this -> initialize ( ) ; $ this -> currentPosition ++ ; if ( isset ( $ this -> metadata [ 'count' ] ) && $ this -> currentPosition > $ this -> metadata [ 'count' ] ) { throw new \ OverflowException ( sprintf ( 'This writer was set up to write %d documents, got more.' , $ this -> metadata [ 'count' ] ) ) ; } fwrite ( $ this -> handle , ",\n" ) ; fwrite ( $ this -> handle , json_encode ( $ document ) ) ; if ( isset ( $ this -> metadata [ 'count' ] ) && $ this -> currentPosition == $ this -> metadata [ 'count' ] ) { $ this -> finalize ( ) ; } }
Writes single document to stream.

@param mixed $document Object to insert into stream.

@throws \OverflowException
Writes single document to stream .