WhichBrowser\Data\DeviceModels::identifyList PHP Method

identifyList() public static method

public static identifyList ( &$index, &$list, $model, $cleanup = true )
    public static function identifyList(&$index, &$list, $model, $cleanup = true)
    {
        $original = $model;
        if ($cleanup) {
            $model = self::cleanup($model);
        }
        $device = new Device(['type' => Constants\DeviceType::MOBILE, 'identified' => Constants\Id::NONE, 'manufacturer' => null, 'model' => $model, 'identifier' => $original, 'generic' => false]);
        $keys = ['@' . strtoupper(substr($model, 0, 2)), '@'];
        $pattern = null;
        $match = null;
        foreach ($keys as $k => $key) {
            if (isset($index[$key])) {
                foreach ($index[$key] as $m => $v) {
                    if (self::hasMatch($v, $model)) {
                        if ($v) {
                            if (substr($v, -2) == "!!") {
                                foreach ($list[$v] as $m2 => $v2) {
                                    if (self::hasMatch($m2, $model)) {
                                        $match = $v2;
                                        $pattern = $m2;
                                        break;
                                    }
                                }
                            } else {
                                $match = $list[$v];
                                $pattern = $v;
                            }
                        }
                        if ($match) {
                            $device->manufacturer = $match[0];
                            $device->model = self::applyMatches($match[1], $model, $pattern);
                            $device->identified = Constants\Id::MATCH_UA;
                            if (isset($match[2]) || isset($match['type'])) {
                                $type = isset($match[2]) ? $match[2] : $match['type'];
                                if (is_array($type)) {
                                    $device->type = $type[0];
                                    $device->subtype = $type[1];
                                } else {
                                    $device->type = $type;
                                }
                            }
                            if (isset($match[3]) || isset($match['flag'])) {
                                $device->flag = isset($match[3]) ? $match[3] : $match['flag'];
                            }
                            if (isset($match['carrier'])) {
                                $device->carrier = $match['carrier'];
                            }
                            if ($device->manufacturer == null && $device->model == null) {
                                $device->identified = Constants\Id::PATTERN;
                            }
                            return $device;
                        }
                    }
                }
            }
        }
        return $device;
    }