Skip to content

Commit

Permalink
Add shortcuts for accessing useful UA Information.
Browse files Browse the repository at this point in the history
  • Loading branch information
andres-montanez committed Feb 16, 2014
1 parent ed008d4 commit c1461e9
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@
.Trashes
ehthumbs.db
Thumbs.db

.buildpath

.project
27 changes: 27 additions & 0 deletions Entity/UserAgent.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,33 @@ public function isMobile()
return in_array($this->getDeviceId(), array(self::DEVICE_SMARTPHONE, self::DEVICE_TABLET, self::DEVICE_WERABLE, self::DEVICE_PDA));
}

public function isIphone()
{
if ($this->isPhone() && $this->getOperatingSystemFamily() == 'iOS') {
return true;
}

return false;
}

public function isIpad()
{
if ($this->isTablet() && $this->getOperatingSystemFamily() == 'iOS') {
return true;
}

return false;
}

public function isAndroid()
{
if ($this->isMobile() && $this->getOperatingSystemFamily() == 'Android') {
return true;
}

return false;
}

public function getType()
{
return $this->type;
Expand Down
63 changes: 63 additions & 0 deletions Service/UserAgentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,67 @@ public function getCurrent()
return $this->currentUserAgent;
}

/**
* Check if current UserAgent is from a Desktop
* @return boolean
*/
public function isDesktop()
{
return $this->getCurrent()->isDesktop();
}

/**
* Check if current UserAgent is from a Phone or Smartphone
* @return boolean
*/
public function isPhone()
{
return $this->getCurrent()->isPhone();
}

/**
* Check if current UserAgent is from a Tablet
* @return boolean
*/
public function isTablet()
{
return $this->getCurrent()->isTablet();
}

/**
* Check if current UserAgent is from a Mobile Device
* @return boolean
*/
public function isMobile()
{
return $this->getCurrent()->isMobile();
}

/**
* Check if current UserAgent is from an Apple iPhone
* @return boolean
*/
public function isIphone()
{
return $this->getCurrent()->isIphone();
}

/**
* Check if current UserAgent is from an Apple iPad
* @return boolean
*/
public function isIpad()
{
return $this->getCurrent()->isIpad();
}

/**
* Check if current UserAgent is from an Android
* @return boolean
*/
public function isAndroid()
{
return $this->getCurrent()->isAndroid();
}

}

0 comments on commit c1461e9

Please sign in to comment.