Fix: PHPCS

This commit is contained in:
Laurent Destailleur 2014-07-28 19:55:12 +02:00
parent 827bf4b22a
commit 3011ecf6df
2 changed files with 34 additions and 30 deletions

View File

@ -23,6 +23,9 @@
* @version 2.8.3 * @version 2.8.3
*/ */
/**
* Class to manage detection of type of terminal (classic, tablet, mobile)
*/
class MobileDetect class MobileDetect
{ {
/** /**
@ -548,10 +551,8 @@ class MobileDetect
* @param string $userAgent Inject the User-Agent header. If null, will use HTTP_USER_AGENT * @param string $userAgent Inject the User-Agent header. If null, will use HTTP_USER_AGENT
* from the $headers array instead. * from the $headers array instead.
*/ */
public function __construct( public function __construct(array $headers = null, $userAgent = null)
array $headers = null, {
$userAgent = null
){
$this->setHttpHeaders($headers); $this->setHttpHeaders($headers);
$this->setUserAgent($userAgent); $this->setUserAgent($userAgent);
} }
@ -574,6 +575,7 @@ class MobileDetect
* *
* @param array $httpHeaders The headers to set. If null, then using PHP's _SERVER to extract * @param array $httpHeaders The headers to set. If null, then using PHP's _SERVER to extract
* the headers. The default null is left for backwards compatibilty. * the headers. The default null is left for backwards compatibilty.
* @return void
*/ */
public function setHttpHeaders($httpHeaders = null) public function setHttpHeaders($httpHeaders = null)
{ {
@ -691,10 +693,11 @@ class MobileDetect
* Set the detection type. Must be one of self::DETECTION_TYPE_MOBILE or * Set the detection type. Must be one of self::DETECTION_TYPE_MOBILE or
* self::DETECTION_TYPE_EXTENDED. Otherwise, nothing is set. * self::DETECTION_TYPE_EXTENDED. Otherwise, nothing is set.
* *
* @deprecated since version 2.6.9
*
* @param string $type The type. Must be a self::DETECTION_TYPE_* constant. The default * @param string $type The type. Must be a self::DETECTION_TYPE_* constant. The default
* parameter is null which will default to self::DETECTION_TYPE_MOBILE. * parameter is null which will default to self::DETECTION_TYPE_MOBILE.
* @return void
*
* @deprecated since version 2.6.9
*/ */
public function setDetectionType($type = null) public function setDetectionType($type = null)
{ {
@ -869,11 +872,12 @@ class MobileDetect
/** /**
* Magic overloading method. * Magic overloading method.
* *
* @method boolean is[...]() * @param string $name Name
* @param string $name * @param array $arguments Arguments
* @param array $arguments
* @return mixed * @return mixed
*
* @throws BadMethodCallException when the method doesn't exist and doesn't start with 'is' * @throws BadMethodCallException when the method doesn't exist and doesn't start with 'is'
* @method boolean is[...]()
*/ */
public function __call($name, $arguments) public function __call($name, $arguments)
{ {
@ -915,8 +919,8 @@ class MobileDetect
* If the key is found the try to match the corresponding * If the key is found the try to match the corresponding
* regex agains the User-Agent. * regex agains the User-Agent.
* *
* @param string $key * @param string $key Key
* @param null $userAgent deprecated * @param string $userAgent deprecated
* @return mixed * @return mixed
*/ */
protected function matchUAAgainstKey($key, $userAgent = null) protected function matchUAAgainstKey($key, $userAgent = null)
@ -941,8 +945,9 @@ class MobileDetect
/** /**
* Check if the device is mobile. * Check if the device is mobile.
* Returns true if any type of mobile device detected, including special ones * Returns true if any type of mobile device detected, including special ones
* @param null $userAgent deprecated *
* @param null $httpHeaders deprecated * @param string $userAgent deprecated
* @param string $httpHeaders deprecated
* @return bool * @return bool
*/ */
public function isMobile($userAgent = null, $httpHeaders = null) public function isMobile($userAgent = null, $httpHeaders = null)
@ -990,12 +995,13 @@ class MobileDetect
/** /**
* This method checks for a certain property in the * This method checks for a certain property in the
* userAgent. * userAgent.
* @todo: The httpHeaders part is not yet used.
* *
* @param string $key * @param string $key key
* @param string $userAgent deprecated * @param string $userAgent deprecated
* @param string $httpHeaders deprecated * @param string $httpHeaders deprecated
* @return bool|int|null * @return bool|int|null
*
* @todo: The httpHeaders part is not yet used.
*/ */
public function is($key, $userAgent = null, $httpHeaders = null) public function is($key, $userAgent = null, $httpHeaders = null)
{ {
@ -1018,12 +1024,11 @@ class MobileDetect
* because of the diversity of devices, vendors and * because of the diversity of devices, vendors and
* their conventions in representing the User-Agent or * their conventions in representing the User-Agent or
* the HTTP headers. * the HTTP headers.
*
* This method will be used to check custom regexes against * This method will be used to check custom regexes against
* the User-Agent string. * the User-Agent string.
* *
* @param $regex * @param string $regex Regex
* @param string $userAgent * @param string $userAgent User agent
* @return bool * @return bool
* *
* @todo: search in the HTTP headers too. * @todo: search in the HTTP headers too.
@ -1049,11 +1054,10 @@ class MobileDetect
/** /**
* Prepare the version number. * Prepare the version number.
* *
* @todo Remove the error supression from str_replace() call.
*
* @param string $ver The string version, like "2.6.21.2152"; * @param string $ver The string version, like "2.6.21.2152";
*
* @return float * @return float
*
* @todo Remove the error supression from str_replace() call.
*/ */
public function prepareVersionNo($ver) public function prepareVersionNo($ver)
{ {

View File

@ -156,7 +156,7 @@ function getBrowserInfo()
$firefox=0; $firefox=0;
if (in_array($name,array('firefox','iceweasel'))) $firefox=1; if (in_array($name,array('firefox','iceweasel'))) $firefox=1;
include_once DOL_DOCUMENT_ROOT.'/core/class/MobileDetect.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/mobiledetect.class.php';
$detectmobile=new MobileDetect(); $detectmobile=new MobileDetect();
$phone=$detectmobile->isMobile(); $phone=$detectmobile->isMobile();
$tablet=$detectmobile->isTablet(); $tablet=$detectmobile->isTablet();