Newscoop\TemplateList\BaseList::parseConstraintsString PHP Метод

parseConstraintsString() защищенный Метод

Parses the constraints string and returns an array of words
protected parseConstraintsString ( string $constraintsString ) : array
$constraintsString string
Результат array
    protected function parseConstraintsString($constraintsString)
    {
        if (empty($constraintsString)) {
            return array();
        }
        $words = array();
        $escaped = false;
        $lastWord = '';
        foreach (str_split($constraintsString) as $char) {
            if (preg_match('/[\\s]/', $char) && !$escaped) {
                if (strlen($lastWord) > 0) {
                    if ($lastWord == "''") {
                        $lastWord = '';
                    }
                    $words[] = $lastWord;
                    $lastWord = '';
                }
            } elseif ($char == "\\" && !$escaped) {
                $escaped = true;
            } else {
                $lastWord .= $char;
                $escaped = false;
            }
        }
        if (strlen($lastWord) > 0) {
            if ($lastWord == "''") {
                $lastWord = '';
            }
            $words[] = $lastWord;
        }
        return $words;
    }