mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-30 19:50:12 +02:00
refactored Decorator pattern
This commit is contained in:
18
Structural/Decorator/ExtraBed.php
Normal file
18
Structural/Decorator/ExtraBed.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace DesignPatterns\Structural\Decorator;
|
||||
|
||||
class ExtraBed extends BookingDecorator
|
||||
{
|
||||
private const PRICE = 30;
|
||||
|
||||
public function calculatePrice(): int
|
||||
{
|
||||
return $this->booking->calculatePrice() + self::PRICE;
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->booking->getDescription() . ' with extra bed';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user