Update StatisticManager.php (#218)

* Update StatisticManager.php

Fix warning PHP 7.3

* Update StatisticManager.php

Rollback change inside foreach
This commit is contained in:
jonthekiller 2019-04-27 19:31:06 +02:00 committed by Lukas Kremsmayr
parent 0c28d683f5
commit 3a10908d25

View File

@ -282,7 +282,7 @@ class StatisticManager implements UsageInformationAble {
} }
foreach ($times as $key => $time) { foreach ($times as $key => $time) {
if (!$time || !isset($hits[$key])) { if (!$time || !isset($hits[$key])) {
continue; continue;
} }
$statsArray[$key] = intval($hits[$key]) / (intval($time) / 3600); $statsArray[$key] = intval($hits[$key]) / (intval($time) / 3600);
} }
@ -296,7 +296,7 @@ class StatisticManager implements UsageInformationAble {
} }
foreach ($shots as $key => $shot) { foreach ($shots as $key => $shot) {
if (!$shot || !isset($hits[$key])) { if (!$shot || !isset($hits[$key])) {
continue; continue;
} }
$statsArray[$key] = intval($hits[$key]) / (intval($shot)); $statsArray[$key] = intval($hits[$key]) / (intval($shot));
} }
@ -310,7 +310,7 @@ class StatisticManager implements UsageInformationAble {
} }
foreach ($shots as $key => $shot) { foreach ($shots as $key => $shot) {
if (!$shot || !isset($hits[$key])) { if (!$shot || !isset($hits[$key])) {
continue; continue;
} }
$statsArray[$key] = intval($hits[$key]) / (intval($shot)); $statsArray[$key] = intval($hits[$key]) / (intval($shot));
} }
@ -324,7 +324,7 @@ class StatisticManager implements UsageInformationAble {
} }
foreach ($shots as $key => $shot) { foreach ($shots as $key => $shot) {
if (!$shot || !isset($hits[$key])) { if (!$shot || !isset($hits[$key])) {
continue; continue;
} }
$statsArray[$key] = intval($hits[$key]) / (intval($shot)); $statsArray[$key] = intval($hits[$key]) / (intval($shot));
} }
@ -338,7 +338,7 @@ class StatisticManager implements UsageInformationAble {
} }
foreach ($shots as $key => $shot) { foreach ($shots as $key => $shot) {
if (!$shot || !isset($hits[$key])) { if (!$shot || !isset($hits[$key])) {
continue; continue;
} }
$statsArray[$key] = intval($hits[$key]) / (intval($shot)); $statsArray[$key] = intval($hits[$key]) / (intval($shot));
} }
@ -392,67 +392,67 @@ class StatisticManager implements UsageInformationAble {
switch ($stat->name) { switch ($stat->name) {
case self::SPECIAL_STAT_KD_RATIO: case self::SPECIAL_STAT_KD_RATIO:
if (!isset($playerStats[StatisticCollector::STAT_ON_KILL]) || !isset($playerStats[StatisticCollector::STAT_ON_DEATH])) { if (!isset($playerStats[StatisticCollector::STAT_ON_KILL]) || !isset($playerStats[StatisticCollector::STAT_ON_DEATH])) {
continue; break;
} }
$kills = intval($playerStats[StatisticCollector::STAT_ON_KILL][1]); $kills = intval($playerStats[StatisticCollector::STAT_ON_KILL][1]);
$deaths = intval($playerStats[StatisticCollector::STAT_ON_DEATH][1]); $deaths = intval($playerStats[StatisticCollector::STAT_ON_DEATH][1]);
if (!$deaths) { if (!$deaths) {
continue; break;
} }
$playerStats[$stat->name] = array($stat, $kills / $deaths); $playerStats[$stat->name] = array($stat, $kills / $deaths);
break; break;
case self::SPECIAL_STAT_HITS_PH: case self::SPECIAL_STAT_HITS_PH:
if (!isset($playerStats[StatisticCollector::STAT_PLAYTIME]) || !isset($playerStats[StatisticCollector::STAT_ON_HIT])) { if (!isset($playerStats[StatisticCollector::STAT_PLAYTIME]) || !isset($playerStats[StatisticCollector::STAT_ON_HIT])) {
continue; break;
} }
$hits = intval($playerStats[StatisticCollector::STAT_ON_HIT][1]); $hits = intval($playerStats[StatisticCollector::STAT_ON_HIT][1]);
$time = intval($playerStats[StatisticCollector::STAT_PLAYTIME][1]); $time = intval($playerStats[StatisticCollector::STAT_PLAYTIME][1]);
if (!$time) { if (!$time) {
continue; break;
} }
$playerStats[$stat->name] = array($stat, $hits / ($time / 3600)); $playerStats[$stat->name] = array($stat, $hits / ($time / 3600));
break; break;
case self::SPECIAL_STAT_ARROW_ACC: case self::SPECIAL_STAT_ARROW_ACC:
if (!isset($playerStats[StatisticCollector::STAT_ARROW_HIT]) || !isset($playerStats[StatisticCollector::STAT_ARROW_SHOT])) { if (!isset($playerStats[StatisticCollector::STAT_ARROW_HIT]) || !isset($playerStats[StatisticCollector::STAT_ARROW_SHOT])) {
continue; break;
} }
$hits = intval($playerStats[StatisticCollector::STAT_ARROW_HIT][1]); $hits = intval($playerStats[StatisticCollector::STAT_ARROW_HIT][1]);
$shots = intval($playerStats[StatisticCollector::STAT_ARROW_SHOT][1]); $shots = intval($playerStats[StatisticCollector::STAT_ARROW_SHOT][1]);
if (!$shots) { if (!$shots) {
continue; break;
} }
$playerStats[$stat->name] = array($stat, $hits / $shots); $playerStats[$stat->name] = array($stat, $hits / $shots);
break; break;
case self::SPECIAL_STAT_LASER_ACC: case self::SPECIAL_STAT_LASER_ACC:
if (!isset($playerStats[StatisticCollector::STAT_LASER_HIT]) || !isset($playerStats[StatisticCollector::STAT_LASER_SHOT])) { if (!isset($playerStats[StatisticCollector::STAT_LASER_HIT]) || !isset($playerStats[StatisticCollector::STAT_LASER_SHOT])) {
continue; break;
} }
$hits = intval($playerStats[StatisticCollector::STAT_LASER_HIT][1]); $hits = intval($playerStats[StatisticCollector::STAT_LASER_HIT][1]);
$shots = intval($playerStats[StatisticCollector::STAT_LASER_SHOT][1]); $shots = intval($playerStats[StatisticCollector::STAT_LASER_SHOT][1]);
if (!$shots) { if (!$shots) {
continue; break;
} }
$playerStats[$stat->name] = array($stat, $hits / $shots); $playerStats[$stat->name] = array($stat, $hits / $shots);
break; break;
case self::SPECIAL_STAT_ROCKET_ACC: case self::SPECIAL_STAT_ROCKET_ACC:
if (!isset($playerStats[StatisticCollector::STAT_ROCKET_HIT]) || !isset($playerStats[StatisticCollector::STAT_ROCKET_SHOT])) { if (!isset($playerStats[StatisticCollector::STAT_ROCKET_HIT]) || !isset($playerStats[StatisticCollector::STAT_ROCKET_SHOT])) {
continue; break;
} }
$hits = intval($playerStats[StatisticCollector::STAT_ROCKET_HIT][1]); $hits = intval($playerStats[StatisticCollector::STAT_ROCKET_HIT][1]);
$shots = intval($playerStats[StatisticCollector::STAT_ROCKET_SHOT][1]); $shots = intval($playerStats[StatisticCollector::STAT_ROCKET_SHOT][1]);
if (!$shots) { if (!$shots) {
continue; break;
} }
$playerStats[$stat->name] = array($stat, $hits / $shots); $playerStats[$stat->name] = array($stat, $hits / $shots);
break; break;
case self::SPECIAL_STAT_NUCLEUS_ACC: case self::SPECIAL_STAT_NUCLEUS_ACC:
if (!isset($playerStats[StatisticCollector::STAT_NUCLEUS_HIT]) || !isset($playerStats[StatisticCollector::STAT_NUCLEUS_SHOT])) { if (!isset($playerStats[StatisticCollector::STAT_NUCLEUS_HIT]) || !isset($playerStats[StatisticCollector::STAT_NUCLEUS_SHOT])) {
continue; break;
} }
$hits = intval($playerStats[StatisticCollector::STAT_NUCLEUS_HIT][1]); $hits = intval($playerStats[StatisticCollector::STAT_NUCLEUS_HIT][1]);
$shots = intval($playerStats[StatisticCollector::STAT_NUCLEUS_SHOT][1]); $shots = intval($playerStats[StatisticCollector::STAT_NUCLEUS_SHOT][1]);
if (!$shots) { if (!$shots) {
continue; break;
} }
$playerStats[$stat->name] = array($stat, (float) ($hits / $shots)); $playerStats[$stat->name] = array($stat, (float) ($hits / $shots));
break; break;