src/Support/UserAgent/Agents/Original.php
protected function parse()
    {
        try {
            $data = app(Browscap::class)->getBrowser($this->userAgent);
        } catch (Exception $e) {
            return;
        }

        foreach ($data as $key => $value) {
            // Force lowercase on key
            $key = strtolower($key);

            // Remove whitespaces from value
            $value = trim($value);

            // Switch it up!
            switch ($key) {
                case 'ismobiledevice':
                    $this->isMobile = !empty($value);
                    break;
                case 'istablet':
                    $this->isTablet = !empty($value);
                    break;
                case 'crawler':
                    $this->isCrawler = !empty($value);
                    break;
                case 'majorver':
                    $this->majorVersion = (int) $value;
                    break;
                case 'minorver':
                    $this->minorVersion = (int) $value;
                    break;
                case 'device_type':
                    $this->device = $value;
                    break;
                case 'device_pointing_method':
                    $this->devicePointer = $value;
                    break;
                case 'browser_maker':
                    $this->publisher = $value;
                    break;
                case 'comment':
                    $this->browserWithVersion = $value;
                    break;
                case 'browser':
                case 'platform':
                    $this->{$key} = $value;
                    break;
            }
        }

        // Set version and if major and minor
        // wasn't present in the data array
        // we'll set them as well
        $this->setVersion($data->version);

        // Mark parsing as successful
        $this->successful = true;
    }
protected function parse()
    {
        try {
            $data = app(Browscap::class)->getBrowser($this->userAgent);
        } catch (Exception $e) {
            return;
        }

        foreach ($data as $key => $value) {
            // Force lowercase on key
            $key = strtolower($key);

            // Remove whitespaces from value
            $value = trim($value);

            // Switch it up!
            switch ($key) {
                case 'ismobiledevice':
                    $this->isMobile = !empty($value);
                    break;
                case 'istablet':
                    $this->isTablet = !empty($value);
                    break;
                case 'crawler':
                    $this->isCrawler = !empty($value);
                    break;
                case 'majorver':
                    $this->majorVersion = (int) $value;
                    break;
                case 'minorver':
                    $this->minorVersion = (int) $value;
                    break;
                case 'device_type':
                    $this->device = $value;
                    break;
                case 'device_pointing_method':
                    $this->devicePointer = $value;
                    break;
                case 'browser_maker':
                    $this->publisher = $value;
                    break;
                case 'comment':
                    $this->browserWithVersion = $value;
                    break;
                case 'browser':
                case 'platform':
                    $this->{$key} = $value;
                    break;
            }
        }

        // Set version and if major and minor
        // wasn't present in the data array
        // we'll set them as well
        $this->setVersion($data->version);

        // Mark parsing as successful
        $this->successful = true;
    }
protected function parse ( ) { try { $ data = app ( Browscap :: class ) -> getBrowser ( $ this -> userAgent ) ; } catch ( Exception $ e ) { return ; } foreach ( $ data as $ key => $ value ) { // Force lowercase on key $ key = strtolower ( $ key ) ; // Remove whitespaces from value $ value = trim ( $ value ) ; // Switch it up! switch ( $ key ) { case 'ismobiledevice' : $ this -> isMobile = ! empty ( $ value ) ; break ; case 'istablet' : $ this -> isTablet = ! empty ( $ value ) ; break ; case 'crawler' : $ this -> isCrawler = ! empty ( $ value ) ; break ; case 'majorver' : $ this -> majorVersion = ( int ) $ value ; break ; case 'minorver' : $ this -> minorVersion = ( int ) $ value ; break ; case 'device_type' : $ this -> device = $ value ; break ; case 'device_pointing_method' : $ this -> devicePointer = $ value ; break ; case 'browser_maker' : $ this -> publisher = $ value ; break ; case 'comment' : $ this -> browserWithVersion = $ value ; break ; case 'browser' : case 'platform' : $ this -> { $ key } = $ value ; break ; } } // Set version and if major and minor // wasn't present in the data array // we'll set them as well $ this -> setVersion ( $ data -> version ) ; // Mark parsing as successful $ this -> successful = true ; }
Parse user agent with the help from Browscap.

@author Morten Rugaard <moru@nodes.dk>

@return void
Parse user agent with the help from Browscap .