Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
75.00% |
3 / 4 |
CRAP | |
50.00% |
5 / 10 |
| BankAccount | |
0.00% |
0 / 1 |
|
75.00% |
3 / 4 |
8.12 | |
50.00% |
5 / 10 |
| getBalance | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| setBalance | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 5 |
|||
| depositMoney | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| withdrawMoney | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| <?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(); | |
| } | |
| } |