Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface Door
- {
- public function getWidth(): float;
- public function getHeight(): float;
- }
- class WoodenDoor implements Door
- {
- protected $width;
- protected $height;
- public function __construct(float $width, float $height)
- {
- $this->width = $width;
- $this->height = $height;
- }
- public function getWidth(): float
- {
- return $this->width;
- }
- public function getHeight(): float
- {
- return $this->height;
- }
- class DoorFactory
- {
- public static function makeDoor($width, $height): Door
- {
- return new WoodenDoor($width, $height);
- }
- }
- //And then it can be used as
- $door = DoorFactory::makeDoor(100, 200);
- echo 'Width: ' . $door->getWidth();
- echo 'Height: ' . $door->getHeight();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement