serbanghita / Mobile-Detect

Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.

Home Page:http://mobiledetect.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use getters (ie. getTabletDevices())

pquerner opened this issue · comments

(Using version 2.8.34)

We have getters like public static function getTabletDevices() but they dont seem to be used; which makes it hard to overwrite, or add stuff to the big regex data arrays, for instance protected static $tabletDevices.

If we want to extend the class Mobile_Detect and add to the $tabletDevices data array by extending getTabletDevices it would be the easiest way.

Ie this:

foreach (self::$tabletDevices as $_regex) {
            if ($this->match($_regex, $userAgent)) {
                return true;
            }
        }

changes to

foreach (static::getTabletDevices() as $_regex) {
    if ($this->match($_regex, $userAgent)) {
        return true;
    }
}

And then the extending class can overwrite getTabletDevices properly.

@pquerner you have a point, can you submit a PR? Are you using PHP5?

Yes I can give you a PR. I'll do that in the coming days.
I have an application stuck on PHP 7.0 for now, hence why I am on the 2.x Branch. :(

@pquerner 👍 I made changes to 3.74.x branch and will publish soon

@serbanghita I saw. I commented on the commit, can you check it please?