forked from matomo-org/plugin-VisitorGenerator
/
Generator.php
53 lines (45 loc) · 1.14 KB
/
Generator.php
1
2
3
4
5
6
7
8
9
10
11
12
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
52
53
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\VisitorGenerator;
use Piwik\SettingsPiwik;
include_once __DIR__ . '/libs/Faker/autoload.php';
class Generator
{
protected $faker;
protected $piwikUrl;
/**
* @param null $piwikUrl
*/
public function __construct($piwikUrl = null)
{
$this->faker = \Faker\Factory::create('en_EN');
$this->faker->addProvider(new Faker\Request($this->faker));
$this->setPiwikUrl($piwikUrl);
}
/**
* @param $piwikUrl
*/
protected function setPiwikUrl($piwikUrl) {
$this->piwikUrl = $piwikUrl;
}
/**
* @return string
*/
protected function getPiwikUrl()
{
if($this->piwikUrl) {
$url = $this->piwikUrl;
} else {
$url = SettingsPiwik::getPiwikUrl();
}
// this is a workaround when force_ssl=1, and the HTTPS URL is not fetchable from CLI
$url = str_replace('https://localhost', 'http://localhost', $url);
return $url;
}
}