~tcuthbert/wordpress/openstack-objectstorage

« back to all changes in this revision

Viewing changes to vendor/phpunit/php-code-coverage/tests/_files/BankAccount.php

  • Committer: Jacek Nykis
  • Date: 2015-02-11 15:35:31 UTC
  • Revision ID: jacek.nykis@canonical.com-20150211153531-hmy6zi0ov2qfkl0b
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
    }
 
33
}