Author: Thomas Müller (t_mueller_stolzenhain@yahoo.de)
Example #1
0
 /**
  * Load a devices.json file and parse it into the platforms data array
  *
  * @param string $src Name of the file
  *
  * @throws \RuntimeException             if the file does not exist or has invalid JSON
  * @throws \UnexpectedValueException     if the properties and the inherits kyewords are missing
  * @return \Browscap\Data\DataCollection
  */
 public function addDevicesFile($src)
 {
     $json = $this->loadFile($src);
     $deviceFactory = new Factory\DeviceFactory();
     foreach ($json['devices'] as $deviceName => $deviceData) {
         if (!isset($deviceData['properties']) && !isset($deviceData['inherits'])) {
             throw new \UnexpectedValueException('required attibute "properties" is missing');
         }
         $this->devices[$deviceName] = $deviceFactory->build($deviceData, $json, $deviceName);
     }
     $this->divisionsHaveBeenSorted = false;
     return $this;
 }