mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-06 15:06:31 +02:00
more simple an concise example of AbstractFactory
This commit is contained in:
18
Creational/AbstractFactory/ProductFactory.php
Normal file
18
Creational/AbstractFactory/ProductFactory.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace DesignPatterns\Creational\AbstractFactory;
|
||||
|
||||
class ProductFactory
|
||||
{
|
||||
const SHIPPING_COSTS = 50;
|
||||
|
||||
public function createShippableProduct(int $price): Product
|
||||
{
|
||||
return new ShippableProduct($price, self::SHIPPING_COSTS);
|
||||
}
|
||||
|
||||
public function createDigitalProduct(int $price): Product
|
||||
{
|
||||
return new DigitalProduct($price);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user