I understand the factory pattern on a simple form but not much if the class requires multiple nested dependencies. E.g.,
$cfg = new Cfg();
$cfg->setA('a');
$cfg->setB('b');
$qux = new Qux('x');
$bar = new Bar($cfg, $qux);
$foo = new Foo($cfg, $bar);
In the above example, how do you properly make a factory pattern for class Foo
so that when you run $factory->build();
you get an instance of Foo
with all its dependencies?
Aucun commentaire:
Enregistrer un commentaire