Writes data to the server.

@param  string                     $data Data to write
@throws \mako\redis\RedisException
@return int
556761
public function write(string $data): int
	{
		$totalBytesWritten = 0;

		$bytesLeft = strlen($data);

		do
		{
			$totalBytesWritten += $bytesWritten = fwrite($this->connection, $data);

			if($bytesWritten === false || $bytesWritten === 0)
			{
				throw new RedisException('Failed to write data to the server.');
			}

			$bytesLeft -= $bytesWritten;

			$data = substr($data, $bytesWritten);
		}
		while($bytesLeft > 0);

		return $totalBytesWritten;
	}
1100029
private function writeData($data) {
        $count = fwrite($this->connection, $data.EOL_WINDOWS, strlen($data)+2);

        if ($count != strlen($data)+2)
            throw new RuntimeException('Error writing to socket, length of data: '.(strlen($data)+2).', bytes written: '.$count.NL.'data: '.$data.NL.NL.'SMTP transfer log:'.NL.'------------------'.NL.$this->logBuffer);

        $this->logSentData($data);
    }
14561
public function write($data)
    {
        if ($this->isOpen() === false) {
            $msg = "Cannot write in a closed MemoryStream.";
            throw new MemoryStreamException($msg, $this, MemoryStreamException::NOT_OPEN);
        }
        
        if ($this->length - 1 === $this->position) {
            // simply append.
            $this->binary .= $data;
        } elseif ($this->position === 0) {
            // simply prepend.
            $this->binary = ($data . $this->binary);
        } else {
            // we are in the middle of the string.
            $part1 = substr($this->binary, 0, $this->position);
            $part2 = substr($this->binary, $this->position);
            $this->binary = ($part1 . $data . $part2);
        }

        $dataLen = strlen($data);
        $this->incrementPosition($dataLen);
        $this->incrementLength($dataLen);

        return $dataLen;
    }
205261
public function sendData( $data )
    {
        if ( is_resource( $this->connection ) )
        {
            if ( fwrite( $this->connection, $data . self::CRLF,
                        strlen( $data ) + strlen( self::CRLF  ) ) === false )
            {
                throw new ezcMailTransportException( 'Could not write to the stream. It was probably terminated by the host.' );
            }
        }
    }
1159353
public function setData($data)
    {
        $body = new Doozr_Response_Body();
        $body->write($data);

        $this->setBody($body);
    }
726820
public function stream_write($data)
    {
        $tmp = &$this->_data[$this->_datapos];

        $oldlen = $tmp['l'];
        $res = fwrite($tmp['fp'], $data);
        if ($res === false) {
            return false;
        }

        $tmp['p'] = ftell($tmp['fp']);
        if ($tmp['p'] > $oldlen) {
            $tmp['l'] = $tmp['p'];
            $this->_length += ($tmp['l'] - $oldlen);
        }

        return $res;
    }
850243
public function redislize($data)
    {
        // Only serialize if it's not a string or a integer
        if (!is_string($data) && !is_int($data)) {
            return urlencode(serialize($data));
        }
        // Encode string to escape wrong saves
        return urlencode($data);
    }
1225715
public static function save($data)
	{
		$instance = self::getInstance();

		// Merge and make sure values are unique
		$data = $instance->merge($instance->config->toArray(), $data);
		$data = $instance->unique($data);

		// Set data back to the instance
		$instance->config = new Registry($data);

		// Actually write out the data
		$instance->write();

		return true;
	}
874777
public function stream_write( $data )
    {
        $left            = substr( $this->string, 0, $this->position );
        $right           = substr( $this->string, $this->position + strlen( $data ) );
        $this->string    = $left . $data . $right;
        $this->position += $written = strlen( $data );
        $this->length    = strlen( $this->string );
        return $written;
    }
1335220
public function write($data)
    {
        if (!$this->connected) {
            if (!$this->connect()) {
                return false;
            }
        }
        return fwrite($this->connection, $data, strlen($data));
    }
1247774
public function write(string $data) : void
    {
        if ($this->closed) {
            throw new IoException('The stream is closed.');
        }

        try {
            $result = ErrorCatcher::run(function() use ($data) {
                return fwrite($this->handle, $data);
            });
        } catch (\ErrorException $e) {
            throw new IoException($e->getMessage(), 0, $e);
        }

        if ($result === false) {
            throw new IoException('Failed to write to stream.');
        }
    }
37047
public function write($data) : bool
    {
        $success = false;

        if ($this->isFile() && $this->isWriteable()) {
            $success = file_put_contents($this->realPath, $data) !== false;
        }

        return $success;
    }
1300148
public function write($data)
    {
        $this->connect();

        $data .= self::EOL;
        $bytesWritten = strlen($data);
        $bytesSent    = fwrite($this->connection, $data, $bytesWritten);

        if ($bytesSent !== $bytesWritten) {
            $this->disconnect();
            throw new Exception\SocketException('Failed to write data.');
        }

        return $this;
    }
218519
public function writeLine($data)
    {
        if (!is_resource($this->fp)) {
            return $this->raiseError('not connected');
        }

        return fwrite($this->fp, $data . $this->newline);
    }
1089440
public function writeLine(string $data): void
	{
		try
		{
			$this->write($data."\r\n");
		}
		catch (\Exception $e)
		{
			throw $e;
		}
	}
363560
protected function _write($data) {
		if (!$this->connected && !$this->connect()) {
			return false;
		}

		$data .= "\r\n";
		return fwrite($this->_connection, $data, strlen($data));
	}
1041494
public function stream_write($data)
    {
        if ($this->fileHandle === null) {
            return false;
        }
        self::restore();
        $length = fwrite($this->fileHandle, $data);
        self::register();
        return $length;
    }