public function isId($id) { if (!$id) { return false; } if ($id instanceof ObjectID) { return true; } try { new ObjectID($id); } catch (\MongoDB\Driver\Exception\InvalidArgumentException $e) { return false; } return true; }