Team Ai
Apppublic

errorcode418/php

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
OperatingSystemParser.php39 linesDownload Raw Back to src
1<?php2/**3 * ua-parser4 *5 * Copyright (c) 2011-2013 Dave Olsen, http://dmolsen.com6 * Copyright (c) 2013-2014 Lars Strojny, http://usrportage.de7 *8 * Released under the MIT license9 */10namespace UAParser;11 12use UAParser\Result\OperatingSystem;13 14class OperatingSystemParser extends AbstractParser15{16    /**17     * Attempts to see if the user agent matches an operating system regex from regexes.php18     *19     * @param string $userAgent a user agent string to test20     * @return OperatingSystem21     */22    public function parseOperatingSystem($userAgent)23    {24        $os = new OperatingSystem();25 26        list($regex, $matches) = self::tryMatch($this->regexes['os_parsers'], $userAgent);27 28        if ($matches) {29            $os->family = self::multiReplace($regex, 'os_replacement', $matches[1], $matches);30            $os->major = self::multiReplace($regex, 'os_v1_replacement', $matches[2], $matches);31            $os->minor = self::multiReplace($regex, 'os_v2_replacement', $matches[3], $matches);32            $os->patch = self::multiReplace($regex, 'os_v3_replacement', $matches[4], $matches);33            $os->patchMinor = self::multiReplace($regex, 'os_v4_replacement', $matches[5], $matches);34        }35 36        return $os;37    }38}39