Automattic\WooCommerce\Vendor\Detection

MobileDetect::matchUAAgainstKey()protectedWC 1.0

Search for a certain key in the rules array. If the key is found then try to match the corresponding regex against the User-Agent.

Method of the class: MobileDetect{}

No Hooks.

Return

true|false.

Usage

// protected - for code of main (parent) or child class
$result = $this->matchUAAgainstKey( $key ): bool;
$key(string) (required)
-

MobileDetect::matchUAAgainstKey() code WC 9.4.2

protected function matchUAAgainstKey(string $key): bool
{
    // Make the keys lowercase, so we can match: isIphone(), isiPhone(), isiphone(), etc.
    $key = strtolower($key);
    if (false === isset($this->cache[$key])) {
        // change the keys to lower case
        $_rules = array_change_key_case($this->getRules());

        if (false === empty($_rules[$key])) {
            $this->cache[$key] = $this->match($_rules[$key]);
        }

        if (false === isset($this->cache[$key])) {
            $this->cache[$key] = false;
        }
    }

    return $this->cache[$key];
}