Well, my point was that validating in the function does no good: it'll raise an error you'll see in the logs and debug later to try and understand what caused it.
Why not write the test that makes sure your code will never call the function with bad input and be done with it?
And, you should write a test. Period. A factory isn't needed and the bunch of shit is only if you're using version < 3.0.
Did you really miss this in the post? That's good input, thanks, and thanks for reading!