private function compare($object, $array)
{
foreach ($object as $property => $value) {
if (is_array($value)) {
foreach ($value as $index => $nestedObject) {
if ($nestedObject->id) {
$foundMatch = FALSE;
//order might be different
foreach ($array[$property] as $k => $a) {
if ($a['id'] == $nestedObject->id) {
$foundMatch = TRUE;
$index = $k;
}
}
if (!$foundMatch) {
throw new \Exception('failed to find match for object ' . $nestedObject->id);
}
}
$this->compare($nestedObject, $array[$property][$index]);
}
} elseif (!is_object($value)) {
asrt(strval($array[$property]), strval($value));
}
}
}