Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can factory methods return multiple instances?

It is a factory method if it returns an instance of a class but is it a factory method if it returns multiple (an array of) instances?

like image 663
Emanuil Rusev Avatar asked Feb 19 '11 09:02

Emanuil Rusev


1 Answers

If you need it to return multiple instances, then do it, regardless of how it is called. I would say it is indeed a factory method, but this doesn't matter that much.

Perhaps you can have a factory method for returning a single instance, and then another one that calls the first one multiple times.

like image 191
Bozho Avatar answered Sep 22 '22 20:09

Bozho