Skip to content

Instantly share code, notes, and snippets.

@sauloarruda
Created April 12, 2010 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sauloarruda/364056 to your computer and use it in GitHub Desktop.
Save sauloarruda/364056 to your computer and use it in GitHub Desktop.
<?
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