Using $this when not in object context

Hi,

I am using ServerRequest::is(‘mobile’) to get if it is mobile device or not. but it will give me this error Using $this when not in object context.

What context are you in? If you are in a controller’s method (which seems likely) the request is available as a property or method of $this (the controller).

class SomeController {

   public function someAction() {
      $this->request->is('mobile');
      $this->getRequest()->is('mobile');
   }
}