PageRenderTime 18ms CodeModel.GetById 16ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 1<?php
 2class BankAccount
 3{
 4    protected $balance = 0;
 5
 6    public function getBalance()
 7    {
 8        return $this->balance;
 9    }
10
11    protected function setBalance($balance)
12    {
13        if ($balance >= 0) {
14            $this->balance = $balance;
15        } else {
16            throw new RuntimeException;
17        }
18    }
19
20    public function depositMoney($balance)
21    {
22        $this->setBalance($this->getBalance() + $balance);
23
24        return $this->getBalance();
25    }
26
27    public function withdrawMoney($balance)
28    {
29        $this->setBalance($this->getBalance() - $balance);
30
31        return $this->getBalance();
32    }
33}