Slide 74
Slide 74 text
abstract class ProductFactory
{
public function __construct(ReferenceGenerator $generator)
{
$this->refGenerator = $generator;
}
abstract protected function createProduct($name, $price, $mass = null, $volume = null);
public function newProduct($name, $price, $mass = null, $volume = null)
{
$price = new Price($price, new Currency('EUR'));
$product = $this->createProduct($name, $price, $mass, $volume);
$product->setReference($this->refGenerator->generate($product));
return $product;
}
}
Usage