/vendor/phpunit/php-code-coverage/tests/_files/BankAccount.php
https://bitbucket.org/alan_cordova/api-sb-map · PHP · 33 lines · 27 code · 6 blank · 0 comment · 2 complexity · 1fa57c931da01a8107b82bcf4b1fb15c MD5 · raw file
- <?php
- class BankAccount
- {
- protected $balance = 0;
- public function getBalance()
- {
- return $this->balance;
- }
- protected function setBalance($balance)
- {
- if ($balance >= 0) {
- $this->balance = $balance;
- } else {
- throw new RuntimeException;
- }
- }
- public function depositMoney($balance)
- {
- $this->setBalance($this->getBalance() + $balance);
- return $this->getBalance();
- }
- public function withdrawMoney($balance)
- {
- $this->setBalance($this->getBalance() - $balance);
- return $this->getBalance();
- }
- }