Created
April 12, 2010 22:14
-
-
Save sauloarruda/364056 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
class Produto { | |
} | |
class PesquisaProdutos extends AppModel { | |
/** | |
* Busca os produtos conforme os parâmetros do filtro | |
* @return array de Produto | |
*/ | |
function buscar() { | |
} | |
} | |
class Voucher { | |
static function validar($codigo) { | |
$voucher = buscarPorCodigo($codigo); | |
// Não existente | |
if ($voucher == null) { | |
throw new VoucherException('voucher.exceptions.naoExistente'); | |
} | |
// Já usado | |
if ($voucher->usado()) { | |
throw new VoucherException('voucher.exceptions.usado'); | |
} | |
if ($voucher->vencido()) { | |
throw new VoucherException('voucher.exceptions.vencido'); | |
} | |
return $voucher; | |
} | |
} | |
class VoucherException extends Exception { | |
var $mensagem; | |
} | |
class VoucherController extends AppController { | |
function validar($codigo = null) { | |
try { | |
$voucher = Voucher::validar($codigo); | |
switch ($voucher->produto->tipo()) { | |
case ProdutoTipo::EXPERIENCIA: | |
return $this->redirecionarExperienca($voucher); | |
} | |
} catch ($e) { | |
$this->flash['erro'] = I18n::key($e->message); | |
} | |
} | |
} | |
class ProdutoValor { | |
/** Relação entre pontos x reais (atual: 2:1) */ | |
static var $cotacao = 2; | |
static function emReais($produto) {} | |
static function emPontos($produto) {} | |
static function diferenca($produto, $voucher, $usuario) {} | |
} | |
class Agendamento { | |
static function calendarioMes($fornecedor, $data) { | |
//... | |
} | |
static function calendarioSemana($fornecedor, $data) { | |
//... | |
} | |
static function CalendarioDia($function, $data) { | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment