TeamTNT\TNTSearch\Support\Expression::lex PHP Method

lex() public method

public lex ( $string )
    public function lex($string)
    {
        $bad = [' or ', '-', ' ', '@', '.'];
        $good = ['|', '~', '&', '&', '&'];
        $string = str_replace($bad, $good, $string);
        $string = mb_strtolower($string);
        $tokens = [];
        $token = "";
        foreach (str_split($string) as $char) {
            if ($this->isOperator($char)) {
                if ($token) {
                    $tokens[] = $token;
                }
                $tokens[] = $char;
                $token = "";
            } else {
                $token .= $char;
            }
        }
        if ($token) {
            $tokens[] = $token;
        }
        return $tokens;
    }