class AcmeFactory
{
public static function anvil()
{
$crud = new Crud;
$productTypes = new ProductTypes($crud);
$productImages = new ProductImages($crud);
$product = new Anvils ($crud, $productImages);
$productManager = new ProductManager ($productTypes, $product);
return $productManager;
}
public static function jetPack()
{
$crud = new Crud;
$productTypes = new ProductTypes($crud);
$productImages = new ProductImages($crud);
$product = new JetPacks ($crud, $productImages);
$productManager = new ProductManager ($productTypes, $product);
return $productManager;
}
}
I know the above code works, but am I using the factory pattern correctly?
The intended result is this:
$anvil = new AcmeFactory::anvil();
$anvil->create($weight);
$anvil->display($id);
.....