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
+12 -12
View File
@@ -7,7 +7,7 @@ use Battles\Database\Db;
class User
{
use Users;
private static ?self $_instance = null;
private static ?self $instance = null;
private ?UserProfile $profile = null;
private ?UserEffect $effect = null;
private ?UserStats $stats = null;
@@ -19,6 +19,7 @@ class User
protected int $experience = 0;
protected int $battle = 0;
protected int $zayavka = 0;
private object $profileData;
protected function __construct($user = null)
{
@@ -28,10 +29,10 @@ class User
// Отсекаем 2.0000~
$col = ctype_digit(strval($user)) ? 'id' : 'login';
$query = "select * from users where $col = ?";
$user_query = Db::getInstance()->fetch($query, $user);
$userQuery = Db::getInstance()->fetch($query, $user);
foreach ($this as $key => $value) {
if (isset($user_query[$key])) {
$this->$key = $user_query[$key];
if (isset($userQuery[$key])) {
$this->$key = $userQuery[$key];
}
}
@@ -48,10 +49,10 @@ class User
public static function getInstance($user = null): self
{
if (is_null(self::$_instance)) {
self::$_instance = new self($user);
if (is_null(self::$instance)) {
self::$instance = new self($user);
}
return self::$_instance;
return self::$instance;
}
public function profile(): UserProfile
@@ -100,7 +101,6 @@ class User
return $this->userMoney;
}
public function getId(): int
{
return $this->id;
@@ -128,11 +128,11 @@ class User
}
/**
* @param string|null $short_name Короткое название клана. Передать null для очистки.
* @param string|null $shortName Короткое название клана. Передать null для очистки.
*/
public function setClan(?string $short_name)
public function setClan(?string $shortName)
{
$this->clan = is_null($short_name) ? null : $short_name;
$this->clan = is_null($shortName) ? null : $shortName;
$this->saveUser();
}
@@ -224,4 +224,4 @@ class User
Db::getInstance()->execute($query, $vals);
}
}
}