<?php
interface Shape {
public function draw();
}
class Retangulo implements Shape {
public function draw(){
return 'Desenhando Retângulo...';
}
}
class Circulo implements Shape {
public function draw(){
return 'Desenhando Círculo...';
}
}
class ShapeFactory {
private $shape;
public function __construct(Shape $shape){
$this->shape = $shape;
}
public function draw(){
echo $this->shape->draw();
}
}
$retangulo = new Retangulo();
$circulo = new Circulo();
$shape = new ShapeFactory($retangulo);
$shape->draw();