public function __construct(array $objects = [])
{
foreach ($objects as $id => $object) {
if ($object instanceof ObjectInterface) {
if ($id !== $object->getId()) {
throw InvalidArgumentExceptionFactory::createForReferenceKeyMismatch($id, $object->getId());
}
$this->objects[$id] = $object;
$this->array[$id] = $object->getInstance();
continue;
}
$this->objects[$id] = new CompleteObject(new SimpleObject($id, $object));
$this->array[$id] = $object;
}
}