1
0
mirror of https://github.com/jupeter/clean-code-php.git synced 2025-09-26 05:59:04 +02:00

Merge pull request #127 from peter-gribanov/balance

Rename methods in BankAccount
This commit is contained in:
Tomáš Votruba
2017-10-07 10:14:29 +02:00
committed by GitHub

View File

@@ -1129,7 +1129,7 @@ class BankAccount
$this->balance = $balance; $this->balance = $balance;
} }
public function withdrawBalance(int $amount): void public function withdraw(int $amount): void
{ {
if ($amount > $this->balance) { if ($amount > $this->balance) {
throw new \Exception('Amount greater than available balance.'); throw new \Exception('Amount greater than available balance.');
@@ -1138,12 +1138,12 @@ class BankAccount
$this->balance -= $amount; $this->balance -= $amount;
} }
public function depositBalance(int $amount): void public function deposit(int $amount): void
{ {
$this->balance += $amount; $this->balance += $amount;
} }
public function getBalance(): int    public function getBalance(): int
{ {
return $this->balance; return $this->balance;
} }
@@ -1152,7 +1152,7 @@ class BankAccount
$bankAccount = new BankAccount(); $bankAccount = new BankAccount();
// Buy shoes... // Buy shoes...
$bankAccount->withdrawBalance($shoesPrice); $bankAccount->withdraw($shoesPrice);
// Get balance // Get balance
$balance = $bankAccount->getBalance(); $balance = $bankAccount->getBalance();