How to use methods?

Hello,
I’m trying to create a Login testcase by using a method.
It’s supposed to look like:

WebUI.openBrowser('<URL>')
login(driver)  //This is my method
WebUI.closeBrowser()

I have two questions:
1)How can I pass the current WebDriver element to my method?
2)I want to have a class that will contain my login() method as a static method (and other static methods in the future).
How do I do that?
Thank you.