If $id is an integer, then the construct of \MongoId will throw an exception because it could not be converted.
So I add a an error control operator, which means If convert is success,then return it,otherwise return origin %id.