public function build(array $platformData, array $json, $platformName)
{
if (!isset($platformData['properties'])) {
$platformData['properties'] = [];
}
if (!array_key_exists('lite', $platformData)) {
throw new \UnexpectedValueException('the value for "lite" key is missing for the platform with the key "' . $platformName . '"');
}
if (!array_key_exists('standard', $platformData)) {
throw new \UnexpectedValueException('the value for "standard" key is missing for the platform with the key "' . $platformName . '"');
}
if (array_key_exists('inherits', $platformData)) {
$parentName = $platformData['inherits'];
if (!isset($json['platforms'][$parentName])) {
throw new \UnexpectedValueException('parent Platform "' . $parentName . '" is missing for platform "' . $platformName . '"');
}
$parentPlatform = $this->build($json['platforms'][$parentName], $json, $parentName);
$parentPlatformData = $parentPlatform->getProperties();
$platformProperties = $platformData['properties'];
foreach ($platformProperties as $name => $value) {
if (isset($parentPlatformData[$name]) && $parentPlatformData[$name] === $value) {
throw new \UnexpectedValueException('the value for property "' . $name . '" has the same value in the keys "' . $platformName . '" and its parent "' . $platformData['inherits'] . '"');
}
}
$platformData['properties'] = array_merge($parentPlatformData, $platformProperties);
if (!$parentPlatform->isLite()) {
$platformData['lite'] = false;
}
if (!$parentPlatform->isStandard()) {
$platformData['standard'] = false;
}
}
return new Platform($platformData['match'], $platformData['properties'], $platformData['lite'], $platformData['standard']);
}