Skip to content

Commit

Permalink
separate function
Browse files Browse the repository at this point in the history
  • Loading branch information
Plancke committed Dec 30, 2016
1 parent 5f5faf9 commit 7ab74d7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/cache/impl/mongo/MongoCacheHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,14 @@ public function selectDB() {
* @param $obj
*/
public function updateCollection($collection, $query, $obj) {
$this->selectDB()->selectCollection($collection)->replaceOne($query, $this->objToArray($obj), ['upsert' => true]);
}

protected function objToArray($obj) {
if ($obj instanceof HypixelObject) {
$this->selectDB()->selectCollection($collection)->replaceOne($query, $obj->getRaw(), ['upsert' => true]);
} else {
$this->selectDB()->selectCollection($collection)->replaceOne($query, $obj, ['upsert' => true]);
return $obj->getRaw();
}
return $obj;
}

/**
Expand Down

0 comments on commit 7ab74d7

Please sign in to comment.