Newer
Older
benakamoorthi
a validé
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
mattab
a validé
use Piwik\Plugins\UserCountry\LocationProvider;
class MockLocationProvider extends LocationProvider
benakamoorthi
a validé
{
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
public static $locations = array();
private $currentLocation = 0;
private $ipToLocations = array();
public function getLocation($info)
{
$ip = $info['ip'];
if (isset($this->ipToLocations[$ip])) {
$result = $this->ipToLocations[$ip];
} else {
$result = self::$locations[$this->currentLocation];
$this->currentLocation = ($this->currentLocation + 1) % count(self::$locations);
$this->ipToLocations[$ip] = $result;
}
$this->completeLocationResult($result);
return $result;
}
public function getInfo()
{
return array('id' => 'mock_provider', 'title' => 'mock provider', 'description' => 'mock provider');
}
public function isAvailable()
{
return true;
}
public function isWorking()
{
return true;
}
public function getSupportedLocationInfo()
{
return array(); // unimplemented
}