Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MongoId to handle psudo MongoId objects (especially when dealing with json)
<?php
class MongoId2 extends MongoId {
public function __construct($id = null) {
if(is_array($id)) {
$id = (object) $id;
}
if(is_object($id) && isset($id->{'$id'})) {
$id = $id->{'$id'};
}
return parent::__construct($id);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.