/** @var Entity $entity */
$entity = new $className($this, $structure, $values, $relations);
if ($values)
{
$class = get_class($entity);
$keys = $entity->getIdentifierValues();
if (!$keys)
{
// must contain nulls, so not a valid entity
if (!($options & self::INSTANTIATE_ALLOW_INVALID))
{
throw new \LogicException("Cannot instantiate $shortName ($className) without primary key values");
}
return null;
}