Hi All.
I'm getting to grips with OOP (slowly) and I was wondering how you go about applying general functions to classes.
For example, if I have a few general functions - this is a silly example, but should give you an idea of what I'm asking:
function strBig($str){
return strtoupper($str);
}
class fixMe{
public function doSentence($str){
return "This is my " . strBig($str);
}
}
$out = new fixMe;
echo $out->doSentence('dog'); //outputs This is my DOG
OK, rubbish example, but the thing is I need to use some formatting functions (e.g. date) that may be used across a number of classes. Would you suggest using the type of thing above - i.e. separate function and class or use a strBig method from a static class (or singleton) for example.
I'm aware that I should be trying to decouple the classes, so any thoughts on this would be appreciated.