forked from matomo-org/matomo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added missing class DeviceDetectorFactory
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/** | ||
* Piwik - Open source web analytics | ||
* | ||
* @link http://piwik.org | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
* | ||
*/ | ||
namespace Piwik; | ||
|
||
use DeviceDetector\DeviceDetector; | ||
|
||
class DeviceDetectorFactory | ||
{ | ||
protected static $deviceDetectorInstances = array(); | ||
|
||
/** | ||
* Returns a Singleton instance of DeviceDetector for the given user agent | ||
* @param string $userAgent | ||
* @return DeviceDetector | ||
*/ | ||
public static function getInstance($userAgent) | ||
{ | ||
if (array_key_exists($userAgent, self::$deviceDetectorInstances)) { | ||
|
||
return self::$deviceDetectorInstances[$userAgent]; | ||
} | ||
|
||
$deviceDetector = new DeviceDetector($userAgent); | ||
$deviceDetector->discardBotInformation(); | ||
$deviceDetector->setCache(new DeviceDetectorCache('tracker', 86400)); | ||
$deviceDetector->parse(); | ||
|
||
self::$deviceDetectorInstances[$userAgent] = $deviceDetector; | ||
|
||
return $deviceDetector; | ||
} | ||
|
||
} |