private function importSchema(Schema $parent, Schema $child)
{
$temp = [];
//add all in a temporary array
if (!is_null($child->properties)) {
foreach ($child->properties as $key => $value) {
$temp[$value->property] = $value;
}
}
//reset the properties
$child->properties = [];
foreach ($parent as $key => $value) {
if ($key == "properties") {
/** @var Property[] $value */
foreach ($value as $property) {
if ($this->isEmpty($property) && isset($temp[$property->property])) {
//if it has the same field
$child->properties[] = $temp[$property->property];
unset($temp[$property->property]);
} else {
$child->properties[] = $property;
}
}
} else {
$child->{$key} = $parent->{$key};
}
}
//now we need to just add the ones in the temp array back in.
foreach ($temp as $name => $temp_item) {
$found = false;
foreach ($child->properties as $property) {
if ($property->property == $name) {
$found = true;
}
}
//if it doesn't already exist then add it
if (!$found) {
$child->properties[] = $temp_item;
}
}
}