diff --git a/DeviceDetector/MobileDetector.php b/DeviceDetector/MobileDetector.php index 759c966..02b00db 100644 --- a/DeviceDetector/MobileDetector.php +++ b/DeviceDetector/MobileDetector.php @@ -19,6 +19,6 @@ * @author suncat2000 * */ -class MobileDetector extends MobileDetect +class MobileDetector extends MobileDetect implements MobileDetectorInterface { } diff --git a/DeviceDetector/MobileDetectorInterface.php b/DeviceDetector/MobileDetectorInterface.php new file mode 100644 index 0000000..a743bbb --- /dev/null +++ b/DeviceDetector/MobileDetectorInterface.php @@ -0,0 +1,76 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace SunCat\MobileDetectBundle\DeviceDetector; + +/** + * MobileDetectorInterface interface + * + * @author pierrickmartos + * + */ +interface MobileDetectorInterface +{ + /** + * Check if the device is mobile. + * Returns true if any type of mobile device detected, including special ones + * @param null $userAgent deprecated + * @param null $httpHeaders deprecated + * @return bool + */ + public function isMobile($userAgent = null, $httpHeaders = null); + + /** + * Check if the device is a tablet. + * Return true if any type of tablet device is detected. + * + * @param string $userAgent deprecated + * @param array $httpHeaders deprecated + * @return bool + */ + public function isTablet($userAgent = null, $httpHeaders = null); + + /** + * This method checks for a certain property in the + * userAgent. + * @todo: The httpHeaders part is not yet used. + * + * @param string $key + * @param string $userAgent deprecated + * @param string $httpHeaders deprecated + * @return bool|int|null + */ + public function is($key, $userAgent = null, $httpHeaders = null); + + /** + * Some detection rules are relative (not standard), + * because of the diversity of devices, vendors and + * their conventions in representing the User-Agent or + * the HTTP headers. + * + * This method will be used to check custom regexes against + * the User-Agent string. + * + * @param $regex + * @param string $userAgent + * @return bool + * + * @todo: search in the HTTP headers too. + */ + public function match($regex, $userAgent = null); + + /** + * Retrieve the mobile grading, using self::MOBILE_GRADE_* constants. + * + * @return string One of the self::MOBILE_GRADE_* constants. + */ + public function mobileGrade(); +} diff --git a/Resources/config/mobile_detect.xml b/Resources/config/mobile_detect.xml index 0311b97..609402f 100644 --- a/Resources/config/mobile_detect.xml +++ b/Resources/config/mobile_detect.xml @@ -14,7 +14,8 @@ - + + diff --git a/composer.json b/composer.json index 19b2f69..31c2f6b 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "php": ">=5.5.9", "symfony/framework-bundle": "~2.7|~3.3|~4.0|~5.0", "mobiledetect/mobiledetectlib": "~2.8", - "twig/twig": "~1.26|~2.0||^3.0" + "twig/twig": "~1.26|~2.0|^3.0" }, "require-dev": { "phpunit/phpunit": "^4.8.35|^5.4.3|^6.0",