Posted: Sat Jul 08, 2006 10:08 pm
Yep. Now you have a self contained class that initializes to reasonable defaults. It can also be "generated" one place in your code and passed to the display code that does not need to know the type of thing is is displaying.
I am not sure if you need all of those setter functions. You could set the properties directly if that is your style, or use __call() if you are using PHP5. Individual setters would be good if you want to specific checks to verify that the values are valid.
Two quibbles on naming. Usually the name of the class is not reused in methods, so the methods CreateTextToolTip() and CreateTextToolTip() could just be CreateText() and CreateLink(). And I have found that it is a good practice to standardize the name of your output functions so they can be used polymorphically -- so the method DisplayToolTip() could just be display() or render() or out() or whatever you generally use.
I am not sure if you need all of those setter functions. You could set the properties directly if that is your style, or use __call() if you are using PHP5. Individual setters would be good if you want to specific checks to verify that the values are valid.
Two quibbles on naming. Usually the name of the class is not reused in methods, so the methods CreateTextToolTip() and CreateTextToolTip() could just be CreateText() and CreateLink(). And I have found that it is a good practice to standardize the name of your output functions so they can be used polymorphically -- so the method DisplayToolTip() could just be display() or render() or out() or whatever you generally use.