Static utility class?
| From: | Micky Hulse | Date: | Wed, 04 Sep 2013 19:25:14 +0000 |
| Subject: | Static utility class? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-322034@lists.php.net to get a copy of this message | ||
Hi all!
Example code:
<https://gist.github.com/mhulse/6441525>
Goal:
I want to have a "utility" class that contain utility methods which should
have the option of being called multiple times on a page.
I think my main goal is to avoid having to "new" things ... I don't really
need to create an instance here (there's no need for a constructor in this
case).
Question:
Is the above simple pattern a good way to have a class that calls static
methods?
To put it another way, is there any reason why I would not want to use the
above code?
Basically I want to wrap these simple functions in a nice class wrapper and
have the ability to call them without having to jump through more hoops
than is necessary.
Are there any pitfalls to writing a class like this? Or, is this the
standard way of writing a simple "utility" class for this type of situation?
Please let me know if I need to clarify my questions.
Thanks for your time?