src/Mapper.php
public function findObjectByProp($type, $name, $value)
    {
        $type = $this->getFullType($type);
        if (class_exists($type)) {
            $table = $type::getCollection();
            $data = $this->mongodb->$table->findOne([$name => $value]);
            if ($data === null) {
                return null;
            }
            return new $type($data, $this->mongodb->$table, $this->cache);
        }
        return null;
    }
public function findObjectByProp($type, $name, $value)
    {
        $type = $this->getFullType($type);
        if (class_exists($type)) {
            $table = $type::getCollection();
            $data = $this->mongodb->$table->findOne([$name => $value]);
            if ($data === null) {
                return null;
            }
            return new $type($data, $this->mongodb->$table, $this->cache);
        }
        return null;
    }
public function findObjectByProp ( $ type , $ name , $ value ) { $ type = $ this -> getFullType ( $ type ) ; if ( class_exists ( $ type ) ) { $ table = $ type :: getCollection ( ) ; $ data = $ this -> mongodb -> $ table -> findOne ( [ $ name => $ value ] ) ; if ( $ data === null ) { return null ; } return new $ type ( $ data , $ this -> mongodb -> $ table , $ this -> cache ) ; } return null ; }
Find object by it's property value and return it
@param string $type Name of class of object that should be returned
@param string $name Name of property to match
@param mixed $value Value of property to match
@return mixed null if document not found, object of type $type otherwise
Find object by it s property value and return it