Code smell.

This commit is contained in:
Ivor Barhansky
2022-12-17 01:20:43 +02:00
parent b1f578f4b0
commit 0398425205
45 changed files with 875 additions and 851 deletions
+9 -9
View File
@@ -7,13 +7,13 @@ use Battles\Database\Db;
class UserMoney
{
private int $uid;
private int $wallet_money;
private int $walletMoney;
private Bank $bank;
public function __construct(int $uid, int $money)
{
$this->uid = $uid;
$this->wallet_money = $money;
$this->walletMoney = $money;
$this->initBank();
}
@@ -24,12 +24,12 @@ class UserMoney
public function get(): int
{
return $this->wallet_money;
return $this->walletMoney;
}
public function set(int $money)
{
$this->wallet_money = max($money, 0);
$this->walletMoney = max($money, 0);
}
public function getBank(): int
@@ -44,14 +44,14 @@ class UserMoney
private function save()
{
Db::getInstance()->execute('update users set money = ? where id = ?', [$this->wallet_money, $this->uid]);
Db::getInstance()->execute('update users set money = ? where id = ?', [$this->walletMoney, $this->uid]);
}
/** Тратим деньги */
public function spend(int $value): bool
{
if ($this->wallet_money > $value && $value > 0) {
$this->wallet_money -= $value;
if ($this->walletMoney > $value && $value > 0) {
$this->walletMoney -= $value;
$this->save();
return true;
}
@@ -64,8 +64,8 @@ class UserMoney
if ($value <= 0) {
return false;
}
$this->wallet_money += $value;
$this->walletMoney += $value;
$this->save();
return true;
}
}
}