DeviceDetector\Parser\ParserAbstract::preMatchOverall PHP Method

preMatchOverall() protected method

All regexes returned by getRegexes() will be reversed and concated with '|' Afterwards the big regex will be tested against the user agent Method can be used to speed up detections by making a big check before doing checks for every single regex
protected preMatchOverall ( ) : boolean
return boolean
    protected function preMatchOverall()
    {
        $regexes = $this->getRegexes();
        static $overAllMatch;
        $cacheKey = $this->parserName . DeviceDetector::VERSION . '-all';
        $cacheKey = preg_replace('/([^a-z0-9_-]+)/i', '', $cacheKey);
        if (empty($overAllMatch)) {
            $overAllMatch = $this->getCache()->fetch($cacheKey);
        }
        if (empty($overAllMatch)) {
            // reverse all regexes, so we have the generic one first, which already matches most patterns
            $overAllMatch = array_reduce(array_reverse($regexes), function ($val1, $val2) {
                if (!empty($val1)) {
                    return $val1 . '|' . $val2['regex'];
                } else {
                    return $val2['regex'];
                }
            });
            $this->getCache()->save($cacheKey, $overAllMatch);
        }
        return $this->matchUserAgent($overAllMatch);
    }