You are here

class BankAccount in Zircon Profile 8

Same name in this branch
  1. 8 vendor/phpunit/phpunit/tests/_files/BankAccount.php \BankAccount
  2. 8 vendor/phpunit/php-code-coverage/tests/_files/BankAccount.php \BankAccount
Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit/tests/_files/BankAccount.php \BankAccount
  2. 8.0 vendor/phpunit/php-code-coverage/tests/_files/BankAccount.php \BankAccount

A bank account.

@since Class available since Release 2.3.0

Hierarchy

Expanded class hierarchy of BankAccount

2 string references to 'BankAccount'
PHP_CodeCoverage_Report_CloverTest::testCloverForBankAccountTest in vendor/phpunit/php-code-coverage/tests/PHP/CodeCoverage/Report/CloverTest.php
@covers PHP_CodeCoverage_Report_Clover
PHP_CodeCoverage_Report_FactoryTest::testSomething in vendor/phpunit/php-code-coverage/tests/PHP/CodeCoverage/Report/FactoryTest.php

File

vendor/phpunit/phpunit/tests/_files/BankAccount.php, line 20

View source
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();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BankAccount::$balance protected property The bank account's balance.
BankAccount::depositMoney public function Deposits an amount of money to the bank account.
BankAccount::getBalance public function Returns the bank account's balance.
BankAccount::setBalance protected function Sets the bank account's balance.
BankAccount::withdrawMoney public function Withdraws an amount of money from the bank account.