Skip to content

Instantly share code, notes, and snippets.

@thiagophx
Created December 31, 2011 20:56
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 thiagophx/1545323 to your computer and use it in GitHub Desktop.
Save thiagophx/1545323 to your computer and use it in GitHub Desktop.
Documentator Specification
<?php
class CompaniaAerea
{
protected $politicaOverbooking;
public function fazReserva(Voo $voo, $numPassageiros)
{
if (!$this->politicaOverbooking->permitida($voo, $numPassageiros))
throw new Exception('BLA');
$voo->numPassageiros += $numPassageiros;
return true;
}
}
class Voo
{
public $capacidadePassageiros = 300;
public $numPassageiros = 120;
}
class PoliticaOverbooking
{
public function permitida(Voo $voo, $numPassageiros)
{
if (($voo->numPassageiros + $numPassageiros) > ($voo->capacidadePassageiros * 1.1))
return false;
return true;
}
}
/*
Apartir de um parsing, seria possivel gerar uma documentação assim:
Compania Aerea faz reserva se a politica overbooking é permitida
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment