parse() public method

public parse ( )
 /**
  * @dataProvider getFixtures
  */
 public function testParse($useragent, $os)
 {
     $osParser = new OperatingSystem();
     $osParser->setUserAgent($useragent);
     $this->assertEquals($os, $osParser->parse());
     self::$osTested[] = $os['short_name'];
 }
Ejemplo n.º 2
0
 private function addTopMenuMobileApp(MenuTop $menu)
 {
     if (empty($_SERVER['HTTP_USER_AGENT'])) {
         return;
     }
     if (!class_exists("DeviceDetector\\DeviceDetector")) {
         throw new \Exception("DeviceDetector could not be found, maybe you are using Piwik from git and need to update Composer. Execute this command: php composer.phar update");
     }
     $ua = new OperatingSystem($_SERVER['HTTP_USER_AGENT']);
     $ua->setCache(new DeviceDetectorCache('tracker', 86400));
     $parsedOS = $ua->parse();
     if (!empty($parsedOS['short_name']) && in_array($parsedOS['short_name'], array(self::DD_SHORT_NAME_ANDROID, self::DD_SHORT_NAME_IOS))) {
         $menu->add('Piwik Mobile App', null, array('module' => 'Proxy', 'action' => 'redirect', 'url' => 'http://piwik.org/mobile/'), true, 4);
     }
 }
Ejemplo n.º 3
0
 protected function parseOs()
 {
     $osParser = new OperatingSystem();
     $osParser->setUserAgent($this->getUserAgent());
     $osParser->setCache($this->getCache());
     $this->os = $osParser->parse();
 }