diff --git a/application/core/Players/Player.php b/application/core/Players/Player.php index 8ebe875c..618610be 100644 --- a/application/core/Players/Player.php +++ b/application/core/Players/Player.php @@ -2,6 +2,7 @@ namespace ManiaControl\Players; +use ManiaControl\Utils\ClassUtil; use ManiaControl\Utils\Formatter; use ManiaControl\ManiaControl; @@ -252,7 +253,7 @@ class Player { * @return mixed */ public function getCache($object, $cacheName) { - $className = $this->getClassName($object); + $className = ClassUtil::getClass($object); if (isset($this->cache[$className . $cacheName])) { return $this->cache[$className . $cacheName]; } @@ -267,18 +268,18 @@ class Player { * @param mixed $data */ public function setCache($object, $cacheName, $data) { - $className = $this->getClassName($object); + $className = ClassUtil::getClass($object); $this->cache[$className . $cacheName] = $data; } /** * Destroys a Cache * - * @param $object + * @param mixed $object * @param $cacheName */ public function destroyCache($object, $cacheName) { - $className = $this->getClassName($object); + $className = ClassUtil::getClass($object); unset($this->cache[$className . $cacheName]); } @@ -328,22 +329,4 @@ class Player { public function dumpCache() { var_dump($this->cache); } - - /** - * Get Class Name of a Parameter - * - * @param mixed $param - * @return string - */ - private function getClassName($param) { - //TODO move in a util or something - if (is_object($param)) { - return get_class($param); - } - if (is_string($param)) { - return $param; - } - trigger_error('Invalid class param. ' . $param); - return (string)$param; - } } diff --git a/application/core/Players/PlayerDataManager.php b/application/core/Players/PlayerDataManager.php index 36c97bdd..fdba975d 100644 --- a/application/core/Players/PlayerDataManager.php +++ b/application/core/Players/PlayerDataManager.php @@ -4,6 +4,7 @@ namespace ManiaControl\Players; use ManiaControl\ManiaControl; +use ManiaControl\Utils\ClassUtil; /** * Player Data Manager @@ -136,7 +137,7 @@ class PlayerDataManager { */ public function defineMetaData($object, $dataName, $default, $dataDescription = '') { $mysqli = $this->maniaControl->database->mysqli; - $className = $this->getClassName($object); + $className = ClassUtil::getClass($object); $query = "INSERT INTO `" . self::TABLE_PLAYERDATAMETADATA . "` ( `class`, @@ -168,23 +169,6 @@ class PlayerDataManager { return true; } - /** - * Get Class Name of a Parameter - * - * @param mixed $param - * @return string - */ - private function getClassName($param) { - if (is_object($param)) { - return get_class($param); - } - if (is_string($param)) { - return $param; - } - trigger_error('Invalid class param. ' . $param); - return (string)$param; - } - /** * Get Type of a Parameter * @@ -221,7 +205,7 @@ class PlayerDataManager { * @return mixed|null */ public function getPlayerData($object, $dataName, Player $player, $serverIndex = -1) { - $className = $this->getClassName($object); + $className = ClassUtil::getClass($object); $meta = $this->metaData[$className . $dataName]; @@ -278,7 +262,7 @@ class PlayerDataManager { * @return bool */ public function setPlayerData($object, $dataName, Player $player, $value, $serverIndex = -1) { - $className = $this->getClassName($object); + $className = ClassUtil::getClass($object); if (!$player) { return false; }