Webiny\Component\Mongo\Bridge\MongoDb::isId PHP Method

isId() public method

Check if given string/object is a valid mongo ID.
public isId ( mixed $id ) : boolean
$id mixed
return boolean
    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;
    }