DeviceDetector\Parser\OperatingSystem::parse PHP Method

parse() public method

public parse ( )
    public function parse()
    {
        $return = array();
        foreach ($this->getRegexes() as $osRegex) {
            $matches = $this->matchUserAgent($osRegex['regex']);
            if ($matches) {
                break;
            }
        }
        if (!$matches) {
            return $return;
        }
        $name = $this->buildByMatch($osRegex['name'], $matches);
        $short = 'UNK';
        foreach (self::$operatingSystems as $osShort => $osName) {
            if (strtolower($name) == strtolower($osName)) {
                $name = $osName;
                $short = $osShort;
            }
        }
        $return = array('name' => $name, 'short_name' => $short, 'version' => $this->buildVersion($osRegex['version'], $matches), 'platform' => $this->parsePlatform());
        if (in_array($return['name'], self::$operatingSystems)) {
            $return['short_name'] = array_search($return['name'], self::$operatingSystems);
        }
        return $return;
    }

Usage Example

コード例 #1
0
 /**
  * @dataProvider getFixtures
  */
 public function testParse($useragent, $os)
 {
     $osParser = new OperatingSystem();
     $osParser->setUserAgent($useragent);
     $this->assertEquals($os, $osParser->parse());
     self::$osTested[] = $os['short_name'];
 }
All Usage Examples Of DeviceDetector\Parser\OperatingSystem::parse