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

rename methods in BankAccount

This commit is contained in:
Peter Gribanov
2017-10-06 11:11:00 +03:00
committed by GitHub
parent b26983358e
commit 40ca2e5959

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 balance(): int
{ {
return $this->balance; return $this->balance;
} }
@@ -1152,10 +1152,10 @@ 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->balance();
``` ```
**[⬆ back to top](#table-of-contents)** **[⬆ back to top](#table-of-contents)**