Skip to content

Commit 8e4e712

Browse files
committed
Model/Characters: Add zone for getCharactersByAccount
clean code
1 parent e44aba9 commit 8e4e712

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

application/models/Characters_model.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,16 @@ public function getCharacters(string $fields, array $where, bool $removeGMs = fa
9191
*/
9292
public function getOnlinePlayers(bool $removeGMs = false): false|array
9393
{
94-
return $this->getCharacters(columns("characters", array("guid", "account", "name", "race", "class", "gender", "level", "zone"), $this->realmId), array(column("characters", "online", false, $this->realmId) => 1), $removeGMs);
94+
return $this->getCharacters(columns("characters", ["guid", "account", "name", "race", "class", "gender", "level", "zone"], $this->realmId), [column("characters", "online", false, $this->realmId) => 1], $removeGMs);
9595
}
9696

9797
/**
9898
* Get the online player count
9999
*
100+
* @param false|string $faction (alliance, horde)
100101
* @return Int
101102
*/
102-
public function getOnlineCount($faction = false)
103+
public function getOnlineCount(bool|string $faction = false): int
103104
{
104105
// Make sure we're connected
105106
$this->connect();
@@ -109,11 +110,11 @@ public function getOnlineCount($faction = false)
109110
$query = $this->db->query("SELECT COUNT(*) as `total` FROM " . table("characters", $this->realmId) . " WHERE " . column("characters", "online", false, $this->realmId) . "='1'");
110111
break;
111112

112-
case "alliance":
113+
case 'alliance':
113114
$query = $this->db->query("SELECT COUNT(*) as `total` FROM " . table("characters", $this->realmId) . " WHERE " . column("characters", "online", false, $this->realmId) . "='1' AND " . column("characters", "race") . " IN(" . implode(",", get_instance()->realms->getAllianceRaces()) . ")");
114115
break;
115116

116-
case "horde":
117+
case 'horde':
117118
$query = $this->db->query("SELECT COUNT(*) as `total` FROM " . table("characters", $this->realmId) . " WHERE " . column("characters", "online", false, $this->realmId) . "='1' AND " . column("characters", "race") . " IN(" . implode(",", get_instance()->realms->getHordeRaces()) . ")");
118119
break;
119120
}
@@ -138,12 +139,12 @@ public function getOnlineCount($faction = false)
138139
}
139140

140141
/**
141-
* Count the characters that belongs to one account
142+
* Count the characters that belong to one account
142143
*
143-
* @param Int $account
144+
* @param Int $account
144145
* @return Int
145146
*/
146-
public function getCharacterCount($account)
147+
public function getCharacterCount(int $account): int
147148
{
148149
$this->connect();
149150

@@ -166,29 +167,28 @@ public function getCharacterCount($account)
166167
}
167168

168169
/**
169-
* Get the characters that belongs to one account
170+
* Get the characters that belong to one account
170171
*
171-
* @param Int $acc
172+
* @param false|Int $acc
172173
* @return Array
173174
*/
174-
public function getCharactersByAccount($acc = false)
175+
public function getCharactersByAccount(false|int $acc = false): array
175176
{
176-
if ($acc == false) {
177+
if (!$acc) {
177178
$CI = &get_instance();
178179
$acc = $CI->user->getId();
179180
}
180181

181-
182-
return $this->getCharacters(columns("characters", array("guid", "name", "race", "class", "gender", "level", "online", "money"), $this->realmId), array(column("characters", "account", false, $this->realmId) => $acc));
182+
return $this->getCharacters(columns("characters", ["guid", "name", "race", "class", "gender", "level", "online", "money", "zone"], $this->realmId), [column("characters", "account", false, $this->realmId) => $acc]);
183183
}
184184

185185
/**
186-
* Get the character guid by the name
186+
* Get the character guid by the name
187187
*
188-
* @param String $name
189-
* @return Int
190-
*/
191-
public function getGuidByName($name)
188+
* @param String $name
189+
* @return false|int
190+
*/
191+
public function getGuidByName(string $name): false|int
192192
{
193193
$this->connect();
194194

0 commit comments

Comments
 (0)