Author: Thomas Müller (t_mueller_stolzenhain@yahoo.de)
Example #1
0
 /**
  * Render a single division
  *
  * @param \Browscap\Data\Division $division
  * @param string                  $divisionName
  *
  * @return array
  */
 private function parseDivision(Division $division, $divisionName)
 {
     $output = [];
     foreach ($division->getUserAgents() as $uaData) {
         $output = array_merge($output, $this->parseUserAgent($uaData, $division->isLite(), $division->isStandard(), $division->getSortIndex(), $divisionName));
     }
     return $output;
 }
Example #2
0
 /**
  * tests setter and getter
  *
  * @group data
  * @group sourcetest
  */
 public function testGetter()
 {
     $name = 'TestName';
     $sortIndex = 42;
     $userAgents = ['abc' => 'def'];
     $versions = [1, 2, 3];
     $object = new Division($name, $sortIndex, $userAgents, true, false, $versions);
     self::assertSame($name, $object->getName());
     self::assertSame($sortIndex, $object->getSortIndex());
     self::assertSame($userAgents, $object->getUserAgents());
     self::assertTrue($object->isLite());
     self::assertFalse($object->isStandard());
     self::assertSame($versions, $object->getVersions());
 }
Example #3
0
 /**
  * checks if a division should be in the output
  *
  * @param \Browscap\Data\Division $division
  *
  * @return bool
  */
 public function isOutput(Division $division)
 {
     return $division->isLite();
 }
Example #4
0
 /**
  * checks if a division should be in the output
  *
  * @param \Browscap\Data\Division $division
  *
  * @return bool
  */
 public function isOutput(Division $division)
 {
     return $division->isStandard();
 }
Example #5
0
 /**
  * tests setter and getter for versions
  *
  * @group data
  * @group sourcetest
  */
 public function testSetGetVersions()
 {
     $versions = array(1, 2, 3);
     self::assertSame($this->object, $this->object->setVersions($versions));
     self::assertSame($versions, $this->object->getVersions());
 }
Example #6
0
 /**
  * Load the file for the default browser
  *
  * @param string $src Name of the file
  *
  * @return \Browscap\Data\DataCollection
  * @throws \RuntimeException if the file does not exist or has invalid JSON
  */
 public function addDefaultBrowser($src)
 {
     $divisionData = $this->loadFile($src);
     $division = new Division();
     $division->setName($divisionData['division'])->setSortIndex((int) $divisionData['sortIndex'])->setUserAgents($divisionData['userAgents'])->setLite(true);
     $this->defaultBrowser = $division;
     $this->divisionsHaveBeenSorted = false;
     return $this;
 }