errorcode418/php
0
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\Client;13 14class Parser extends AbstractParser15{16 /** @var DeviceParser */17 private $deviceParser;18 19 /** @var OperatingSystemParser */20 private $operatingSystemParser;21 22 /** @var UserAgentParser */23 private $userAgentParser;24 25 /**26 * Start up the parser by importing the data file to $this->regexes27 *28 * @param array $regexes29 */30 public function __construct(array $regexes)31 {32 parent::__construct($regexes);33 $this->deviceParser = new DeviceParser($this->regexes);34 $this->operatingSystemParser = new OperatingSystemParser($this->regexes);35 $this->userAgentParser = new UserAgentParser($this->regexes);36 }37 38 /**39 * Sets up some standard variables as well as starts the user agent parsing process40 *41 * @param string $userAgent a user agent string to test, defaults to an empty string42 * @param array $jsParseBits43 * @return Client44 */45 public function parse($userAgent, array $jsParseBits = array())46 {47 $client = new Client($userAgent);48 49 $client->ua = $this->userAgentParser->parseUserAgent($userAgent, $jsParseBits);50 $client->os = $this->operatingSystemParser->parseOperatingSystem($userAgent);51 $client->device = $this->deviceParser->parseDevice($userAgent);52 53 return $client;54 }55}56 