Pop\Web\Mobile::detect PHP Метод

detect() защищенный Метод

Method to detect whether or not the device is a mobile device or not.
protected detect ( ) : boolean
Результат boolean
    protected function detect()
    {
        $matches = array();
        $is = false;
        // Android devices
        if (stripos($this->ua, 'android') !== false) {
            $this->device = 'Android';
            $this->android = true;
            $is = true;
            // Blackberry devices
        } else {
            if (stripos($this->ua, 'blackberry') !== false) {
                $this->device = 'Blackberry';
                $this->blackberry = true;
                $is = true;
                // Windows devices
            } else {
                if (stripos($this->ua, 'windows ce') !== false || stripos($this->ua, 'windows phone') !== false) {
                    $this->device = 'Windows';
                    $this->windows = true;
                    $is = true;
                    // Opera devices
                } else {
                    if (stripos($this->ua, 'opera mini') !== false) {
                        $this->device = 'Opera';
                        $this->opera = true;
                        $is = true;
                        // Palm Pre devices
                    } else {
                        if (stripos($this->ua, 'pre') !== false && stripos($this->ua, 'presto') === false) {
                            $this->device = 'Pre';
                            $this->pre = true;
                            $is = true;
                            // Apple devices
                        } else {
                            if (preg_match('/(ipod|iphone|ipad)/i', $this->ua, $matches) != 0) {
                                $this->device = $matches[0];
                                $this->apple = true;
                                $is = true;
                                // Other devices
                            } else {
                                if (preg_match('/(nokia|symbian|palm|treo|hiptop|avantgo|plucker|xiino|blazer|elaine|teleca|up.browser|up.link|mmp|smartphone|midp|wap|vodafone|o2|pocket|kindle|mobile|pda|psp)/i', $this->ua, $matches) != 0) {
                                    $this->device = $matches[0];
                                    $is = true;
                                }
                            }
                        }
                    }
                }
            }
        }
        if ($is) {
            if (strtolower($this->device) == 'ipad') {
                $this->tablet = true;
            } else {
                $this->tablet = stripos($this->ua, 'mobile') !== false ? false : true;
            }
        }
        return $is;
    }