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);
    }
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);
    }
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 ) ; }
Get structure object from a document's value

@param string $selector
@param string|callable $className string class name or closure, which accept data and return string class name
@return object representation of document with class, passed as argument
@throws \Sokil\Mongo\Exception
Get structure object from a document s value