public function write($string)
    {
        $bytes = $this->remainder . $string;
        $len = strlen($bytes);
        if (($len % 3) !== 0) {
            $this->remainder = substr($bytes, -($len % 3));
            $bytes = substr($bytes, 0, $len - ($len % 3));
        } else {
            $this->remainder = '';
        }
        $this->stream->write(base64_encode($bytes));
        $written = strlen($string);
        $this->position += $len;
        return $written;
    }
public function write($string)
    {
        $bytes = $this->remainder . $string;
        $len = strlen($bytes);
        if (($len % 3) !== 0) {
            $this->remainder = substr($bytes, -($len % 3));
            $bytes = substr($bytes, 0, $len - ($len % 3));
        } else {
            $this->remainder = '';
        }
        $this->stream->write(base64_encode($bytes));
        $written = strlen($string);
        $this->position += $len;
        return $written;
    }
public function write ( $ string ) { $ bytes = $ this -> remainder . $ string ; $ len = strlen ( $ bytes ) ; if ( ( $ len % 3 ) !== 0 ) { $ this -> remainder = substr ( $ bytes , - ( $ len % 3 ) ) ; $ bytes = substr ( $ bytes , 0 , $ len - ( $ len % 3 ) ) ; } else { $ this -> remainder = '' ; } $ this -> stream -> write ( base64_encode ( $ bytes ) ) ; $ written = strlen ( $ string ) ; $ this -> position += $ len ; return $ written ; }
Writes the passed string to the underlying stream after encoding it to
base64.

Base64Stream::close or detach must be called.  Failing to do so may
result in 1-2 bytes missing from the end of the stream if there's a
remainder.  Note that the default Stream destructor calls close as well.

Note that reading and writing to the same stream may result in wrongly
encoded data and is not supported.

@param string $string
@return int the number of bytes written
Writes the passed string to the underlying stream after encoding it to base64 .