A bank account.
@package PHPUnit @author Sebastian Bergmann <sebastian@phpunit.de> @copyright 2001-2013 Sebastian Bergmann <sebastian@phpunit.de> @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License @link http://www.phpunit.de/ @since Class available since Release 2.3.0
Expanded class hierarchy of BankAccount
class BankAccount {
/**
* The bank account's balance.
*
* @var float
*/
protected $balance = 0;
/**
* Returns the bank account's balance.
*
* @return float
*/
public function getBalance() {
return $this->balance;
}
/**
* Sets the bank account's balance.
*
* @param float $balance
* @throws BankAccountException
*/
protected function setBalance($balance) {
if ($balance >= 0) {
$this->balance = $balance;
}
else {
throw new BankAccountException();
}
}
/**
* Deposits an amount of money to the bank account.
*
* @param float $balance
* @throws BankAccountException
*/
public function depositMoney($balance) {
$this
->setBalance($this
->getBalance() + $balance);
return $this
->getBalance();
}
/**
* Withdraws an amount of money from the bank account.
*
* @param float $balance
* @throws BankAccountException
*/
public function withdrawMoney($balance) {
$this
->setBalance($this
->getBalance() - $balance);
return $this
->getBalance();
}
}
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BankAccount:: |
protected | property | The bank account's balance. | |
BankAccount:: |
public | function | Deposits an amount of money to the bank account. | |
BankAccount:: |
public | function | Returns the bank account's balance. | |
BankAccount:: |
protected | function | Sets the bank account's balance. | |
BankAccount:: |
public | function | Withdraws an amount of money from the bank account. |