public function getObject($selector, $className = '\\Sokil\\Mongo\\Structure')
{
$data = $this->get($selector);
if (!$data) {
return null;
}
// get class name from callable
if (is_callable($className)) {
$className = $className($data);
}
// prepare structure
$structure = new $className();
if (!$structure instanceof Structure) {
throw new Exception('Wrong structure class specified');
}
return $structure->merge($data);
}