mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-09 00:16:32 +02:00
more simple an concise example of AbstractFactory
This commit is contained in:
27
Creational/AbstractFactory/ShippableProduct.php
Normal file
27
Creational/AbstractFactory/ShippableProduct.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace DesignPatterns\Creational\AbstractFactory;
|
||||
|
||||
class ShippableProduct implements Product
|
||||
{
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $productPrice;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $shippingCosts;
|
||||
|
||||
public function __construct(int $productPrice, int $shippingCosts)
|
||||
{
|
||||
$this->productPrice = $productPrice;
|
||||
$this->shippingCosts = $shippingCosts;
|
||||
}
|
||||
|
||||
public function calculatePrice(): int
|
||||
{
|
||||
return $this->productPrice + $this->shippingCosts;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user