public function detect()
  {
    $detected = true;
    if ( empty( $this->ua ) )
    {
      $detected = false;
    }
    else
    {
      // If it's not any of the common browsers, perhaps it's something mobile.
      if ( !$this->isMSIE() && !$this->isChrome() && !$this->isFirefox() && !$this->isSafari() && !$this->isEdge() && !$this->isOpera() )
      {
        if ( !$this->isOtherMobile() )
        {
          $detected = false;
        }
      }
      else
      {
        // If it's one of the default browsers, check to see if it's the mobile version.
        if ( !$this->isChromeMobile() && !$this->isSafariMobile() && !$this->isFirefoxMobile() && !$this->isOperaMobile() )
        {
          // If not, check for other mobile conditions, otherwise mark as definitely not mobile.
          if ( !$this->isOtherMobile() )
          {
            $this->mobile = false;
            $this->touch = false;
            $this->android = false;
            $this->ios = false;
            $this->tablet = false;
            $this->phone = false;
          }
        }
      }
    }

    if ( $detected )
    {
      // Deal with Width/Height
      if ( !$this->width )
      {
        $this->width = ( $this->phone ) ? $this->defaultSize[ 'phone' ][ 'width' ] : $this->defaultSize['tablet']['width'];
        $this->height = ( $this->phone ) ? $this->defaultSize[ 'phone' ][ 'height' ] : $this->defaultSize['tablet']['height'];
      }

      // Deal with Browser
      if ( $this->isModern() )
      {
        $browser = 'modern';
      }
      elseif($this->isFallback())
      {
        $browser = 'fallback';
      }
      else
      {
        $browser = 'baseline';
      }

      // Return the array that DeviceFeatureInfo expects.
      return array(
        'hidpi'       => false,
        'width'       => $this->width,
        'height'      => $this->height,
        'low_speed'   => false,
        'low_battery' => false,
        'metered'     => $this->metered,
        'browser'     => $browser,
        'touch'       => $this->touch,
        'android'     => $this->android,
        'ios'         => $this->ios,
        'user-agent'  => $this->ua
      );
    }

    return null;
  }
public function detect()
  {
    $detected = true;
    if ( empty( $this->ua ) )
    {
      $detected = false;
    }
    else
    {
      // If it's not any of the common browsers, perhaps it's something mobile.
      if ( !$this->isMSIE() && !$this->isChrome() && !$this->isFirefox() && !$this->isSafari() && !$this->isEdge() && !$this->isOpera() )
      {
        if ( !$this->isOtherMobile() )
        {
          $detected = false;
        }
      }
      else
      {
        // If it's one of the default browsers, check to see if it's the mobile version.
        if ( !$this->isChromeMobile() && !$this->isSafariMobile() && !$this->isFirefoxMobile() && !$this->isOperaMobile() )
        {
          // If not, check for other mobile conditions, otherwise mark as definitely not mobile.
          if ( !$this->isOtherMobile() )
          {
            $this->mobile = false;
            $this->touch = false;
            $this->android = false;
            $this->ios = false;
            $this->tablet = false;
            $this->phone = false;
          }
        }
      }
    }

    if ( $detected )
    {
      // Deal with Width/Height
      if ( !$this->width )
      {
        $this->width = ( $this->phone ) ? $this->defaultSize[ 'phone' ][ 'width' ] : $this->defaultSize['tablet']['width'];
        $this->height = ( $this->phone ) ? $this->defaultSize[ 'phone' ][ 'height' ] : $this->defaultSize['tablet']['height'];
      }

      // Deal with Browser
      if ( $this->isModern() )
      {
        $browser = 'modern';
      }
      elseif($this->isFallback())
      {
        $browser = 'fallback';
      }
      else
      {
        $browser = 'baseline';
      }

      // Return the array that DeviceFeatureInfo expects.
      return array(
        'hidpi'       => false,
        'width'       => $this->width,
        'height'      => $this->height,
        'low_speed'   => false,
        'low_battery' => false,
        'metered'     => $this->metered,
        'browser'     => $browser,
        'touch'       => $this->touch,
        'android'     => $this->android,
        'ios'         => $this->ios,
        'user-agent'  => $this->ua
      );
    }

    return null;
  }
public function detect ( ) { $ detected = true ; if ( empty ( $ this -> ua ) ) { $ detected = false ; } else { // If it's not any of the common browsers, perhaps it's something mobile. if ( ! $ this -> isMSIE ( ) && ! $ this -> isChrome ( ) && ! $ this -> isFirefox ( ) && ! $ this -> isSafari ( ) && ! $ this -> isEdge ( ) && ! $ this -> isOpera ( ) ) { if ( ! $ this -> isOtherMobile ( ) ) { $ detected = false ; } } else { // If it's one of the default browsers, check to see if it's the mobile version. if ( ! $ this -> isChromeMobile ( ) && ! $ this -> isSafariMobile ( ) && ! $ this -> isFirefoxMobile ( ) && ! $ this -> isOperaMobile ( ) ) { // If not, check for other mobile conditions, otherwise mark as definitely not mobile. if ( ! $ this -> isOtherMobile ( ) ) { $ this -> mobile = false ; $ this -> touch = false ; $ this -> android = false ; $ this -> ios = false ; $ this -> tablet = false ; $ this -> phone = false ; } } } } if ( $ detected ) { // Deal with Width/Height if ( ! $ this -> width ) { $ this -> width = ( $ this -> phone ) ? $ this -> defaultSize [ 'phone' ] [ 'width' ] : $ this -> defaultSize [ 'tablet' ] [ 'width' ] ; $ this -> height = ( $ this -> phone ) ? $ this -> defaultSize [ 'phone' ] [ 'height' ] : $ this -> defaultSize [ 'tablet' ] [ 'height' ] ; } // Deal with Browser if ( $ this -> isModern ( ) ) { $ browser = 'modern' ; } elseif ( $ this -> isFallback ( ) ) { $ browser = 'fallback' ; } else { $ browser = 'baseline' ; } // Return the array that DeviceFeatureInfo expects. return array ( 'hidpi' => false , 'width' => $ this -> width , 'height' => $ this -> height , 'low_speed' => false , 'low_battery' => false , 'metered' => $ this -> metered , 'browser' => $ browser , 'touch' => $ this -> touch , 'android' => $ this -> android , 'ios' => $ this -> ios , 'user-agent' => $ this -> ua ) ; } return null ; }
Detects the various items from the user agent, and returns what it can in the the array format desired by
DeviceFeatureInfo.  If nothing can be detected, returns null.

@return array|null
Detects the various items from the user agent and returns what it can in the the array format desired by DeviceFeatureInfo . If nothing can be detected returns null .