public function findOne($query)
    {
        $entities = $this->find($query);
        if (empty($entities)) {
            return null;
        }

        return current($entities);
    }
public function findOne($query)
    {
        $entities = $this->find($query);
        if (empty($entities)) {
            return null;
        }

        return current($entities);
    }
public function findOne ( $ query ) { $ entities = $ this -> find ( $ query ) ; if ( empty ( $ entities ) ) { return null ; } return current ( $ entities ) ; }
Find document in composition based on given entity or matching query.

$user->cards->findOne(['active' => true]);
$user->cards->findOne(new Card(...));

@param CompositableInterface|array $query

@return CompositableInterface|null
Find document in composition based on given entity or matching query .