paulomartinhago
12/6/2013 - 3:55 PM

teste-padrao.php

<?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();