Write a string into a file

@param string $string The string to write
@param bool   $append Append to file

@return int
181568
public function write($string, $append = true)
    {
        $mode = $this->getMode($append);
        $this->setHandle($mode);

        return fwrite($this->handle, $string);
    }
52719
public function getWriteBuffer(int $length, string $append = ''): Promise
    {
        return call([$this, 'getWriteBufferAsync'], $length, $append);
    }
61273
public final function write($string): int
   {
       if (!$this->isWritable()) {
           throw new RuntimeException("Can't write: stream is not writable");
       }
       $this->meta["eof"] = true;
	   if (($size = (int) fwrite($this->stream, (string) $string))) {
		    $this->meta["size"] = $this->getMetadata("size") + $size;
	   }
       return $size;
   }
159981
public function append($data) {

		if(false === is_string($data)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($data)), E_USER_ERROR);
		}

		if(false !== $this -> file -> getExists()) {

	    	if(false === is_writable($this -> file -> getBasepath())) {
	    		trigger_error(sprintf('File "%s" is not writable', $this -> file -> getBasepath()), E_USER_ERROR);
	    	}

		    $handle = fopen($this -> file -> getBasepath(), 'a');

	    	fwrite($handle, $data);
	    	fclose($handle);
		}

		return $this;
	}
99185
public function getWriteBufferAsync(int $length, string $append = ''): \Generator
    {
        $this->write_buffer = yield $this->stream->getWriteBuffer($length);
        if (strlen($append)) {
            $this->append = $append;
            $this->append_after = $length - strlen($append);
        }

        return $this;
    }
242995
public function append(string $string) {
        for ($i = 0; $i < \strlen($string); $i++) {
            $this->arrayList->add($string[$i]);
        }
    }
535218
public function append( $content )
    {
        $prefix = $this->getPrefix();

        if (is_string( $prefix )) {
            $this->file->fwrite( $prefix . ': ' );
        }

        if (!is_string( $content )) {
            $content = var_export( $content, true );
        }

        $this->file->fwrite( $content );
        $this->file->fwrite( PHP_EOL );
        $this->file->fwrite( PHP_EOL );

        $this->incrementLineCount();
    }
1068252
public function write($string)
    {
        $length = strlen($string);

        $start = substr($this->resource, 0, $this->pointer);
        $end = substr($this->resource, $this->pointer + $length);

        $this->resource = $start . $string . $end;

        $this->pointer = strlen($start . $string);

        return $string;
    }
1342219
public function write($string)
    {
        if (strlen($string) !== $bytesWritten = fwrite($this->getHandle(), $string)) {
            throw new RuntimeException(
                'Buffer could not be written to stream.'
            );
        }

        return $bytesWritten;
    }
336357
public static function write(string $string, string $color = null, $appendTime = true)
    {
        parseColor:
        $prefix = $suffix = '';
        if ($color) {
            $color = strtolower(trim($color));
            switch ($color) {
                case 'blue' :
                    $prefix = "\033[44;37;1m";
                    break;
                case 'green' :
                    $prefix = "\033[42;37;1m";
                    break;
                case 'red' :
                    $prefix = "\033[41;37;1m";
                    break;
                case 'yellow' :
                    $prefix = "\033[43;37;1m";
                    break;
                default:
                    $color = 'blue';
                    goto parseColor;
                    break;
            }

            if ($prefix) {
                $suffix = "\033[0m";
            }

            if (strpos($string, '^^') === false) {
                $hasEof = mb_substr($string, -1, 1) === "\n";
                $string = rtrim($string, "\n");
                $string = '^^' . $string . '$$';
                if ($hasEof) {
                    $string .= "\n";
                }
            }

            $string = str_replace(['^^', '$$'], [$prefix, $suffix], $string);
        }

        if (mb_substr($string, -1, 1) !== "\n") {
            $string .= "\n";
        }

        if ($appendTime) {
            $string = '[' . date('m-d H:i:s') . '] ' . $string;
        }

        echo $string;
    }
582813
public function write($string)
    {
        if ($this->fd) {
            $ret = fwrite($this->fd, $string);
            if ($ret !== FALSE) {
                return $ret; 
            }
        }

        return false;
    }
783663
public function write($string):int {
		if(!$this->isWritable()) {
			throw new StreamException("Stream is not writable");
		}

		return fwrite($this->stream, $string);
	}
509972
public function getWriteBufferAsync(int $length, string $append = ''): \Generator
    {
        $length >>= 2;
        if ($length < 127) {
            $message = chr($length);
        } else {
            $message = chr(127).substr(pack('V', $length), 0, 3);
        }
        $buffer = yield $this->stream->getWriteBuffer(strlen($message) + $length, $append);
        yield $buffer->bufferWrite($message);

        return $buffer;
    }
684447
public static function append($file = false, $content = false) {

        if ($file && $content) {

            if (file_put_contents($file, $content, FILE_APPEND)) {

                return true;
            }
        }

        return false;
    }
108796
public function appendToFile($content)
    {
        $result = @fwrite($this->_file, $content);

        if ($result === false) {
            throw new Exception("I'm can not wrtite to file");
        }

        return $result;
    }
593214
public function append(string $string) : bool
        {
                return $this->_redis->append($this->_key, $string) > 0 ? true : false;
        }
1333504
public static function limitChars($string, $limit = 100, $append = '...'): string
    {
        if (mb_strlen($string) <= $limit) {
            return $string;
        }

        return rtrim(mb_substr($string, 0, $limit)).$append;
    }