3 * This file is part of PHPUnit.
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 class BankAccountException extends RuntimeException
18 * @since Class available since Release 2.3.0
23 * The bank account's balance.
27 protected $balance = 0;
30 * Returns the bank account's balance.
34 public function getBalance()
36 return $this->balance;
40 * Sets the bank account's balance.
42 * @param float $balance
44 * @throws BankAccountException
46 protected function setBalance($balance)
49 $this->balance = $balance;
51 throw new BankAccountException;
56 * Deposits an amount of money to the bank account.
58 * @param float $balance
60 * @throws BankAccountException
62 public function depositMoney($balance)
64 $this->setBalance($this->getBalance() + $balance);
66 return $this->getBalance();
70 * Withdraws an amount of money from the bank account.
72 * @param float $balance
74 * @throws BankAccountException
76 public function withdrawMoney($balance)
78 $this->setBalance($this->getBalance() - $balance);
80 return $this->getBalance();