Adds a suffix to each line of input stream and returns resulting stream.

@param  null $len
@return mixed buffer, -1 on EOF
199364
public function read($len = null)
    {
        if (!$this->getInitialized()) {
            $this->_initialize();
            $this->setInitialized(true);
        }

        $ch = -1;

        if ($this->queuedData !== null && $this->queuedData === '') {
            $this->queuedData = null;
        }

        if ($this->queuedData !== null) {
            $ch = $this->queuedData[0];
            $this->queuedData = substr($this->queuedData, 1);
            if ($this->queuedData === '') {
                $this->queuedData = null;
            }
        } else {
            $this->queuedData = $this->readLine();
            if ($this->queuedData === null) {
                $ch = -1;
            } else {
                if ($this->suffix !== null) {
                    $lf = '';
                    if (StringHelper::endsWith($this->queuedData, "\r\n")) {
                        $lf = "\r\n";
                    } elseif (StringHelper::endsWith($this->queuedData, "\n")) {
                        $lf = "\n";
                    }
                    $this->queuedData = substr($this->queuedData, 0, strlen($this->queuedData) - strlen($lf)) . $this->suffix . $lf;
                }
                return $this->read();
            }
        }
        return $ch;
    }
553465
function generateCode($len)
  {
    $code = '';

    for($i = 1, $cslen = strlen($this->charset); $i <= $len; ++$i) {
      $code .= strtoupper( $this->charset{rand(0, $cslen - 1)} );
    }
    return $code;
  }
253315
public function read($len = null)
    {
        if (!class_exists('XSLTProcessor')) {
            throw new BuildException("Could not find the XSLTProcessor class. Make sure PHP has been compiled/configured to support XSLT.");
        }

        if ($this->processed === true) {
            return -1; // EOF
        }

        if (!$this->getInitialized()) {
            $this->_initialize();
            $this->setInitialized(true);
        }

        // Read XML
        $_xml = null;
        while (($data = $this->in->read($len)) !== -1) {
            $_xml .= $data;
        }

        if ($_xml === null) { // EOF?

            return -1;
        }

        if (empty($_xml)) {
            $this->log("XML file is empty!", Project::MSG_WARN);

            return ''; // return empty string, don't attempt to apply XSLT
        }

        // Read XSLT
        $_xsl = null;
        $br = new BufferedReader(new FileReader($this->xslFile));
        $_xsl = $br->read();

        $this->log(
            "Tranforming XML " . $this->in->getResource() . " using style " . $this->xslFile->getPath(),
            Project::MSG_VERBOSE
        );

        $out = '';
        try {
            $out = $this->process($_xml, $_xsl);
            $this->processed = true;
        } catch (IOException $e) {
            throw new BuildException($e);
        }

        return $out;
    }
37303
public function write($buf, $off = null, $len = null)
    {
        if ($off === null && $len === null) {
            $to_write = $buf;
        } elseif ($off !== null && $len === null) {
            $to_write = substr($buf, $off);
        } elseif ($off === null && $len !== null) {
            $to_write = substr($buf, 0, $len);
        } else {
            $to_write = substr($buf, $off, $len);
        }

        $result = @fwrite($this->stream, $to_write);

        if ($result === false) {
            throw new IOException("Error writing to stream.");
        }
    }
1193995
public function read($length = null)
    {
        $buffer = '';
        $total = count($this->_streams) - 1;
        $remaining = (integer) ($length === null ? $this->_bufferSize : $length);
        $progressToNext = false;

        while ($remaining > 0) {

            // Progress to the next stream if needed.
            if ($progressToNext || $this->_streams[$this->_current]->eof()) {
                $progressToNext = false;
                if ($this->_current === $total) {
                    break;
                }
                $this->_current++;
            }

            $result = $this->_streams[$this->_current]->read($remaining);

            if (!$result) {
                $progressToNext = true;
                continue;
            }

            $buffer .= $result;
            $remaining = $length - strlen($buffer);
        }

        $this->_offset += strlen($buffer);
        return $buffer;
    }
1051915
public function suffix($string)
    {
        if (null === $this->suffix) {
            $this->suffix = $this->element('', [], ' ');
        }

        $args = func_get_args();

        if (!is_array($string) && count($args) > 1) {
            $string = call_user_func_array([$this, 'format'], $args);
        }

        $this->suffix->append($string);

        return $this;
    }
972343
function PrependLength(buffer, len) {
  let lenBuf = new Buffer(4);
  lenBuf.writeUInt32LE(len, 0);
  return Buffer.concat([lenBuf, buffer], buffer.length + 4);
}
562163
public static function getRand($len = 12, $onlyNum = false)
    {
        $chars = $onlyNum ? '0123456789' : 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
        mt_srand((double)microtime() * 1000000 * getmypid());
        $return = '';
        while(strlen($return) < $len){
            $return .= substr($chars, (mt_rand() % strlen($chars)), 1);
        }

        return $return;
    }
1082302
public function read($len = null)
    {
        if (!$this->getInitialized()) {
            $this->_initialize();
            $this->setInitialized(true);
        }

        // read from next filter up the chain
        $buffer = $this->in->read($len);

        if ($buffer === -1) {
            return -1;
        }

        // filter buffer
        $buffer = preg_replace_callback(
            "$" . preg_quote($this->_beginToken) . "([\w\.\-:\/]+?)" . preg_quote($this->_endToken) . "$",
            [$this, 'replaceTokenCallback'],
            $buffer
        );

        return $buffer;
    }
467382
public function split(string $delimiter = null): StreamInterface
    {
        if (\is_null($delimiter) || $delimiter === '') {
            return $this->chunk();
        }

        $parts = \explode($delimiter, $this->value);
        $stream = new Stream(self::class);

        foreach ($parts as $part) {
            $stream = $stream->add(new self($part, $this->encoding));
        }

        return $stream;
    }
870716
public static function len($text, $len)
	{
	    if (is_array($len)) {
	        if (!isset($len['len'])) {
	            throw new \InvalidArgumentException('The $len argument must have "len" key');
	        }
	        $len = $len['minLen'];
	    }

	    return strlen($text) == $len;
	}
1325042
public static function getWords($words, $len)
    {
        $wordParts = explode(' ', $words);

        $sentence = '';

        for ($i = 0; $i < $len; $i++) {
            $sentence .= ' ' . $wordParts[$i];
        }

        return trim($sentence);
    }
958649
protected static function makeBin($str, $len)
    {
        if ($str instanceof self) {
            return $str->bytes;
        }
        if (\strlen($str) === $len) {
            return $str;
        }

        $str = (string)preg_replace([
            // strip URN scheme and namespace
            '/^urn:uuid:/is',
            // strip non-hex characters
            '/[^a-f0-9]/is',
        ], '', $str);

        if (\strlen($str) !== ($len * 2)) {
            return null;
        }

        return pack('H*', $str);
    }
23511
public function getLine($length = null, $ending = "\n")
    {
        $this->_ensureReadable();
        $length = $this->_bufferSize($length);
        if ($length <= 0) {
            return '';
        }
        $result = stream_get_line($this->_resource, $length, $ending);
        return $result === false ? '' : $result;
    }
2623
public function read($len = null)
    {
        if (!$this->getInitialized()) {
            $this->initialize();
            $this->setInitialized(true);
        }

        while (($buffer = $this->in->read($len)) !== -1) {
            // Remove the last "\n" from buffer for
            // prevent explode to add an empty cell at
            // the end of array
            $buffer = trim($buffer, "\n");

            $lines = explode("\n", $buffer);
            $skip = $this->skip > 0 ? $this->skip : 0;

            if (count($lines) >= $this->lines) {
                // Buffer have more (or same) number of lines than needed.
                // Fill lineBuffer with the last "$this->_lines" lasts ones.
                $off = count($lines) - $this->lines;
                if ($skip > 0) {
                    $this->lineBuffer = array_slice($lines, $off - $skip, -$skip);
                } else {
                    $this->lineBuffer = array_slice($lines, $off);
                }
            } else {
                // Some new lines ...
                // Prepare space for insert these new ones
                $this->lineBuffer = array_slice($this->lineBuffer, count($lines) - 1);
                $this->lineBuffer = array_merge($this->lineBuffer, $lines);
            }
        }

        if (empty($this->lineBuffer)) {
            $ret = -1;
        } else {
            $ret = implode("\n", $this->lineBuffer);
            $this->lineBuffer = [];
        }

        return $ret;
    }
1321821
public final LogBuffer duplicate(final int len) {
        if (position + len > origin + limit) throw new IllegalArgumentException("limit excceed: "
                                                                                + (position + len - origin));

        // XXX: Do momery copy avoid buffer modified.
        final int end = position + len;
        byte[] buf = Arrays.copyOfRange(buffer, position, end);
        LogBuffer dupBuffer = new LogBuffer(buf, 0, len);
        position = end;
        return dupBuffer;
    }
968919
public function read($len) {
        // Do a non-blocking read to clear any buffering, even though
        // the code doesn't use the results
        if (is_resource($this->socket_)) {
            @fread($this->socket_, max($len, 8192));
        }

        // Return data from the hard-coded response buffer
        $part = substr($this->respBuffer_, 0, $len);
        $this->respBuffer_ = substr($this->respBuffer_, $len);
        return $part;
    }