Bolt\Twig\Handler\HtmlHandler::isMobileClient PHP Метод

isMobileClient() публичный Метод

Check if the page is viewed on a mobile device.
public isMobileClient ( ) : boolean
Результат boolean
    public function isMobileClient()
    {
        $request = Request::createFromGlobals();
        if (preg_match('/(android|blackberry|htc|iemobile|iphone|ipad|ipaq|ipod|nokia|playbook|smartphone)/i', $request->server->get('HTTP_USER_AGENT'))) {
            return true;
        } else {
            return false;
        }
    }

Usage Example

Пример #1
0
 public function testIsMobileClientInvalid()
 {
     $app = $this->getApp();
     $handler = new HtmlHandler($app);
     $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36';
     $result = $handler->isMobileClient();
     $this->assertFalse($result);
 }