public function build(array $deviceData, array $json, $deviceName)
{
if (!isset($deviceData['properties'])) {
$deviceData['properties'] = [];
}
if (!array_key_exists('standard', $deviceData)) {
throw new \UnexpectedValueException('the value for "standard" key is missing for device "' . $deviceName . '"');
}
if (array_key_exists('inherits', $deviceData)) {
$parentName = $deviceData['inherits'];
if (!isset($json['devices'][$parentName])) {
throw new \UnexpectedValueException('parent Device "' . $parentName . '" is missing for device "' . $deviceName . '"');
}
$parentEngine = $this->build($json['devices'][$parentName], $json, $parentName);
$parentEngineData = $parentEngine->getProperties();
$inheritedPlatformProperties = $deviceData['properties'];
foreach ($inheritedPlatformProperties as $name => $value) {
if (isset($parentEngineData[$name]) && $parentEngineData[$name] === $value) {
throw new \UnexpectedValueException('the value for property "' . $name . '" has the same value in the keys "' . $deviceName . '" and its parent "' . $deviceData['inherits'] . '"');
}
}
$deviceData['properties'] = array_merge($parentEngineData, $inheritedPlatformProperties);
if (!$parentEngine->isStandard()) {
$deviceData['standard'] = false;
}
}
return new Device($deviceData['properties'], $deviceData['standard']);
}