예제 #1
0
 public function pot()
 {
     $content = Pot::generate();
     if (empty($content)) {
         throw new Exception('INTERNAL ERROR', 500);
     }
     header("Content-Disposition: attachment; filename=" . C::g('LANG_DOMAIN_CURRENT') . ".pot");
     header("Content-Type: application/force-download");
     print $content;
 }
예제 #2
0
파일: toss.php 프로젝트: rkgladson/PHPixme
/**
 * @param mixed $x
 * @throws \Error|\Exception|Pot
 * @sig $x -!-> $x|Pot($x)
 * An adapter to throw anything, not just exceptions. It is an identiy on \Throwables
 */
function toss($x)
{
    throw !($x instanceof \Exception || $x instanceof \Error) ? Pot::of($x) : $x;
}
예제 #3
0
/**
 * @param $data
 * @return Pot
 */
function Pot($data)
{
    return Pot::of($data);
}
예제 #4
0
 function potAdd($seat, $bet)
 {
     $this->responses[$seat->num] = $bet;
     foreach ($this->pots as $pi => $pot) {
         if ($bet <= 0) {
             break;
         }
         # nothing to do
         if ($pot->isOpen()) {
             if ($pot->limit === NO_LIMIT) {
                 $pot->add($seat->num, $bet);
                 $bet = 0;
                 break;
             } else {
                 $deficit = $pot->getDeficit($seat);
                 if ($deficit) {
                     $bet -= $deficit;
                     $pot->add($seat->num, $deficit);
                 }
             }
         }
     }
     # left over cash!
     if ($bet > 0) {
         $pot = new Pot();
         $this->pots[] = $pot;
         $pot->add($seat->num, $bet);
     }
 }