PHPDaemon\Network\IOStream::drainIfMatch PHP Метод

drainIfMatch() публичный Метод

Drains buffer it matches the string
public drainIfMatch ( string $str ) : boolean | null
$str string Data
Результат boolean | null Success
    public function drainIfMatch($str)
    {
        if (!isset($this->bev)) {
            return false;
        }
        $in = $this->bev->input;
        $l = mb_orig_strlen($str);
        $ll = $in->length;
        if ($ll === 0) {
            return $l === 0 ? true : null;
        }
        if ($ll < $l) {
            return $in->search(substr($str, 0, $ll)) === 0 ? null : false;
        }
        if ($ll === $l) {
            if ($in->search($str) === 0) {
                $in->drain($l);
                return true;
            }
        } elseif ($in->search($str, 0, $l) === 0) {
            $in->drain($l);
            return true;
        }
        return false;
    }