WhichBrowser\Model\Device::identifyModel PHP Method

identifyModel() public method

Identify the manufacturer and model based on a pattern
public identifyModel ( string $pattern, string $subject, array | null $defaults = [] ) : string
$pattern string The regular expression that defines the group that matches the model
$subject string The string the regular expression is matched with
$defaults array | null An optional array of properties to set together
return string
    public function identifyModel($pattern, $subject, $defaults = [])
    {
        if (preg_match($pattern, $subject, $match)) {
            $this->manufacturer = !empty($defaults['manufacturer']) ? $defaults['manufacturer'] : null;
            $this->model = Data\DeviceModels::cleanup($match[1]);
            $this->identifier = preg_replace('/ (Mozilla|Opera|Obigo|AU.Browser|UP.Browser|Build|Java|PPC|AU-MIC.*)$/iu', '', $match[0]);
            $this->identifier = preg_replace('/_(TD|GPRS|LTE|BLEU|CMCC|CUCC)$/iu', '', $match[0]);
            if (isset($defaults['model'])) {
                if (is_callable($defaults['model'])) {
                    $this->model = call_user_func($defaults['model'], $this->model);
                } else {
                    $this->model = $defaults['model'];
                }
            }
            $this->generic = false;
            $this->identified |= Constants\Id::PATTERN;
            if (!empty($defaults['carrier'])) {
                $this->carrier = $defaults['carrier'];
            }
            if (!empty($defaults['type'])) {
                $this->type = $defaults['type'];
            }
        }
    }