writes given bytes

@param   string  $bytes
@return  int     amount of written bytes
544296
public function write(string $bytes): int
    {
        $isAcceptable = $this->predicate;
        if ($isAcceptable($bytes)) {
            return $this->outputStream->write($bytes);
        }

        return 0;
    }
1282704
public static function fromBytes(string $bytes): Uuid
    {
        if (strlen($bytes) !== 16) {
            $message = sprintf('%s expects $bytes to be a 16-bytes string', __METHOD__);
            throw new DomainException($message);
        }

        $steps = [];
        foreach (range(0, 15) as $i) {
            $steps[] = sprintf('%02x', ord($bytes[$i]));
            if (in_array($i, [3, 5, 7, 9])) {
                $steps[] = '-';
            }
        }

        return static::parse(implode('', $steps));
    }
145637
public function write($bytes, $length)
    {
        $written = fwrite($this->stream, $bytes, $length);

        if ($written !== $length) {
            throw new RuntimeException('Failed to write '.$length.' bytes');
        }

        $this->size = null;

        return $written;
    }
268393
public function formatFilesize($bytes)
    {
        $units = array('bytes', 'kb', 'MB', 'GB', 'TB', 'PB');
        $level = floor(log($bytes)/log(1024));

        $output = sprintf('%.2f %s', ($bytes/pow(1024, floor($level))), $units[$level]);

        return $output;
    }
231957
public static function resizeBytes($bytes)
    {
        static $units = ['b', 'kb', 'mb', 'gb', 'tb', 'pb'];

        /** @noinspection PhpIllegalArrayKeyTypeInspection */

        return @round($bytes / pow(1024, ($i = floor(log($bytes, 1024)))), 2) . $units[$i];
    }
384803
public static function convertSizeToText(string $bytes): string
    {
        $kb = 1 << 10;
        $mb = $kb << 10;
        $gb = $mb << 10;
        $tb = $gb << 10;

        if ($bytes < $kb) {
            return $bytes . ' Б';
        } elseif ($bytes < $mb) {
            return number_format($bytes / $kb, 2, ',', '') . ' КБ';
        } elseif ($bytes < $gb) {
            return number_format($bytes / $mb, 2, ',', '') . ' MБ';
        } elseif ($bytes < $tb) {
            return number_format($bytes / $gb, 2, ',', '') . ' ГБ';
        }

        return number_format($bytes / $tb, 2, ',', '') . ' ТБ';
    }
1196802
public void write(byte[] bytes) throws IOException {
        for (int i = 0; i < bytes.length; i++) {
            write(bytes[i]);
        }
    }
15983
public function stream_write($data)
    {
        if ( ! $this->stream instanceof WritableStream) {
            return 0;
        }

        try {
            return $this->stream->writeBytes($data);
        } catch (Exception $e) {
            trigger_error(sprintf('%s: %s', get_class($e), $e->getMessage()), \E_USER_WARNING);
            return false;
        }
    }
1059367
protected function formatBytes($bytes): string
    {
        $suffix = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];

        $p = min((int)log($bytes, 1024), count($suffix) - 1);

        return sprintf('%1.2f%s', ($bytes / pow(1024, $p)), $suffix[$p]);
    }
133739
public static function formatBytes($bytes)
    {
        $bytes = (double) abs($bytes);
        if ($bytes === 0.0) {
            return '0.00 B';
        }
        //units
        $units = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB');
        $index = (int) (log($bytes)/log(1024));
        //echo $index;
        if ($index > 8) {
            throw new \OutOfRangeException('Input is to large! Maximum supported: 1.236731113465765645724418048 * 10^27 bytes.');
        }
        if ($index === 0) {
            //format
            $output = sprintf('%.2f %s', $bytes, $units[$index]);
        } else {
            //format
            $output = sprintf('%.2f %s', ($bytes/pow(1024, $index)), $units[$index]);
        }

        return $output;
    }
307551
private function read($bytes)
    {
        $read = '';
        $total = $bytes;

        while (!$this->isEndOfFile() && $bytes) {
            if (false === ($chunk = @fread($this->getHandle(), $bytes))) {
                $error = error_get_last();

                throw new RuntimeException($error['message']);
            }

            $read .= $chunk;
            $bytes -= strlen($chunk);
        }

        if ($total !== ($actual = strlen($read))) {
            throw new RuntimeException(
                "Only read $actual bytes of $total from \"{$this->file}\"."
            );
        }

        return $read;
    }
1147723
protected function formatBytes($bytes)
    {
        $bytes = (int) $bytes;

        if ($bytes > 1024 * 1024) {
            return round($bytes / 1024 / 1024, 2) . ' MB';
        }

        if ($bytes > 1024) {
            return round($bytes / 1024, 2) . ' KB';
        }

        return $bytes . ' B';
    }
232491
public function write($string) : int
	{
		if (! \is_resource($this->resource))
		{
			throw new Exception\UnwritableStreamException('Stream is not resourceable');
		}

		if (! $this->isWritable())
		{
			throw new Exception\UnwritableStreamException('Stream is not writable');
		}

		$result = \fwrite($this->resource, $string);

		if (false === $result)
		{
			throw new Exception\UnwritableStreamException('Unable to write to the stream');
		}

		return $result;
	}
311450
public function write($string)
    {
        if ($this->isWritable()) {
            $size = $this->getSize();
            $count = fwrite($this->stream, $string);
            $this->setSize($size + $count);
            return $count;
        } else {
            return false;
        }
    }
1152315
protected function doCommit($bytes)
    {
        if (isset($this->in)) {
            $bytesToWrite = strlen($bytes);
            $totalBytesWritten = 0;

            while ($totalBytesWritten < $bytesToWrite) {
                $bytesWritten = fwrite($this->in, substr($bytes, $totalBytesWritten));
                if (false === $bytesWritten || 0 === $bytesWritten) {
                    break;
                }

                $totalBytesWritten += $bytesWritten;
            }

            if ($totalBytesWritten > 0) {
                return ++$this->sequence;
            }
        }
    }
216932
public function formatFileSize ($bytes)
    {
        $sz = 'BKMGTP';
        $factor = (int) floor((strlen($bytes) - 1) / 3);
        return number_format($bytes / pow(1024, $factor), 2, ",", ".") . @$sz[$factor];
    }
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;
	}