Code Coverage |
||||||||||||||||
Classes and Traits |
Functions and Methods |
Paths |
Branches |
Lines |
||||||||||||
| Total | |
0.00% |
0 / 1 |
|
75.00% |
3 / 4 |
CRAP | |
60.00% |
3 / 5 |
|
42.86% |
3 / 7 |
|
55.56% |
5 / 9 |
| BankAccount | |
0.00% |
0 / 1 |
|
75.00% |
3 / 4 |
6.60 | |
60.00% |
3 / 5 |
|
42.86% |
3 / 7 |
|
55.56% |
5 / 9 |
| getBalance | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|||
| setBalance | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 2 |
|
0.00% |
0 / 4 |
|
0.00% |
0 / 4 |
|||
| depositMoney | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
2 / 2 |
|||
| withdrawMoney | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
2 / 2 |
|||
| 1 | <?php |
| 2 | class 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 | return $this->getBalance(); |
| 33 | } |
| 34 | } |