Skip to content

Instantly share code, notes, and snippets.

@acorncom
Last active December 26, 2015 19:39
Show Gist options
  • Save acorncom/7202468 to your computer and use it in GitHub Desktop.
Save acorncom/7202468 to your computer and use it in GitHub Desktop.
<?php
private $_browser;
private $_objMobileDetect;

public function init()
{
...
}
public setBrowser(Browscap $browser) {};
public function getBrowser() {
if(!isset($this->_browser)) {
$objBrowserCap = new \phpbrowscap\Browscap($this->cachePath);
$this->_browser = $objBrowserCap->getBrowser();
}
return $this->_browser;
}
public setMobileDetect(Mobile_Detect $mobileDetect) {};
public getMobileDetect();
public function isMobileDevice() {
if(!isset($this->defaultBrowser)) {
$this->browser->isMobileDevice = ($browser->isMobileDevice || $objMobileDetect->isMobile());
}
return ($this->browser->isMobileDevice);
}
public function isTabletDevice() {
return ($this->browser->isMobileDevice || $this->mobileDetect->isMobile());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment