Writing a factory for classes that have required arguments
- by Kyle Adams
I understand the concept of factory pattern such that you give it something it spits out something of the same template back so if I gave a factory class apple, I expect to get many apples back with out having to instantiate a new apple ever time.
what if that apple has a required argument of seed, or multiple required arguments of seed, step and leaf? how do you use factory pattern here?
that is how do I use factory pattern to instantiate this:
$apple = new Apple($seed, $stem, $leaf);