Jenssegers\Agent\Agent::findDetectionRulesAgainstUA PHP Method

findDetectionRulesAgainstUA() protected method

Match a detection rule and return the matched key.
protected findDetectionRulesAgainstUA ( array $rules, null $userAgent = null ) : string
$rules array
$userAgent null
return string
    protected function findDetectionRulesAgainstUA(array $rules, $userAgent = null)
    {
        // Loop given rules
        foreach ($rules as $key => $regex) {
            if (empty($regex)) {
                continue;
            }
            // Check match
            if ($this->match($regex, $userAgent)) {
                return $key ?: reset($this->matchesArray);
            }
        }
        return false;
    }