@@ -9,15 +9,15 @@ |
||
| 9 | 9 | use Ps2alerts\Api\Command\TestCommand; |
| 10 | 10 | use Symfony\Component\Console\Application; |
| 11 | 11 | |
| 12 | -require __DIR__ . '/../vendor/autoload.php'; |
|
| 12 | +require __DIR__.'/../vendor/autoload.php'; |
|
| 13 | 13 | |
| 14 | 14 | // ENV loading |
| 15 | 15 | josegonzalez\Dotenv\Loader::load([ |
| 16 | - 'filepath' => __DIR__ . '/../.env', |
|
| 16 | + 'filepath' => __DIR__.'/../.env', |
|
| 17 | 17 | 'toEnv' => true |
| 18 | 18 | ]); |
| 19 | 19 | |
| 20 | -include __DIR__ . '/Command/CommandsCommon.php'; |
|
| 20 | +include __DIR__.'/Command/CommandsCommon.php'; |
|
| 21 | 21 | |
| 22 | 22 | $application = new Application(); |
| 23 | 23 | // List commands here |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | |
| 12 | 12 | protected function configure() |
| 13 | 13 | { |
| 14 | - $container = include __DIR__ . '/../container.php'; |
|
| 14 | + $container = include __DIR__.'/../container.php'; |
|
| 15 | 15 | |
| 16 | 16 | $this->container = $container; |
| 17 | 17 | $this->auraFactory = $container->get('Ps2alerts\Api\Factory\AuraFactory'); |
@@ -77,7 +77,7 @@ |
||
| 77 | 77 | $query->where('playerServer', $server); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - $query->orderBy([$metric . ' DESC']); |
|
| 80 | + $query->orderBy([$metric.' DESC']); |
|
| 81 | 81 | $query->limit($limit); |
| 82 | 82 | $query->offset($count); |
| 83 | 83 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | $alerts = $this->alertRepo->fireStatementAndReturn($query); |
| 74 | 74 | $count = count($alerts); |
| 75 | 75 | |
| 76 | - $output->writeln("Detected {$count} alerts to be archived"); |
|
| 76 | + $output->writeln("detected {$count} alerts to be archived"); |
|
| 77 | 77 | |
| 78 | 78 | if ($count > 0) { |
| 79 | 79 | $tables = [ |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | ['json' => $payload] |
| 116 | 116 | ); |
| 117 | 117 | |
| 118 | - $output->writeln("Archived {$records} records!"); |
|
| 118 | + $output->writeln("archived {$records} records!"); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | $this->recordsArchived += $stm->rowCount(); |
| 184 | 184 | $records += $stm->rowCount(); |
| 185 | 185 | |
| 186 | - $output->writeln("Archived {$stm->rowCount()} from Alert #{$alert['ResultID']} - Table {$table}"); |
|
| 186 | + $output->writeln("archived {$stm->rowCount()} from Alert #{$alert['ResultID']} - Table {$table}"); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | $this->db->commit(); |
@@ -89,7 +89,7 @@ |
||
| 89 | 89 | $query->cols(['*']); |
| 90 | 90 | $query->from('ws_players_total'); |
| 91 | 91 | if ($server != 0) { |
| 92 | - $query->where("playerServer = ?", $server); |
|
| 92 | + $query->where("playerServer = ?", $server); |
|
| 93 | 93 | } |
| 94 | 94 | $query->orderBy([$metric.' DESC']); |
| 95 | 95 | $query->limit($limit); |
@@ -127,7 +127,7 @@ |
||
| 127 | 127 | /** |
| 128 | 128 | * Checks formatting of dates input and then adds them to query |
| 129 | 129 | * |
| 130 | - * @param mixed $dates |
|
| 130 | + * @param string $dates |
|
| 131 | 131 | * @param AbstractQuery $query |
| 132 | 132 | * @param boolean $raw Determines if query is being used in raw mode |
| 133 | 133 | * |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | // Format into strings comma separated for SQL |
| 101 | 101 | if (in_array($type, $strings)) { |
| 102 | - $queryString = "'" . implode("','", $values) . "'"; |
|
| 102 | + $queryString = "'".implode("','", $values)."'"; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | return $queryString; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | $return = implode(',', $filters); |
| 119 | 119 | |
| 120 | 120 | if (in_array($type, $strings)) { |
| 121 | - $return = "'" . implode("','", $filters) . "'"; |
|
| 121 | + $return = "'".implode("','", $filters)."'"; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | return $return; |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | public function addDateRangeWhereClause($dates, AbstractQuery $query, $raw = false) |
| 137 | 137 | { |
| 138 | - if (! is_array($dates)) { |
|
| 138 | + if (!is_array($dates)) { |
|
| 139 | 139 | $dates = str_replace('\'', '', $dates); // Remove escaping quotes |
| 140 | 140 | $dates = explode(',', $dates); |
| 141 | 141 | } |
@@ -75,7 +75,7 @@ |
||
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | if ($type !== 'dates' && !in_array($val, $filters)) { |
| 78 | - throw new InvalidArgumentException("Unrecognized {$type}. Please check the DATA you sent."); |
|
| 78 | + throw new InvalidArgumentException("unrecognized {$type}. Please check the DATA you sent."); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | if ($type === 'dates') { |
@@ -250,6 +250,9 @@ discard block |
||
| 250 | 250 | return $this->respondWithData($results); |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | + /** |
|
| 254 | + * @param integer $classID |
|
| 255 | + */ |
|
| 253 | 256 | private function findClassGrouping($classID) |
| 254 | 257 | { |
| 255 | 258 | $classGroups = $this->getConfig()['classesGroups']; |
@@ -265,6 +268,9 @@ discard block |
||
| 265 | 268 | return false; |
| 266 | 269 | } |
| 267 | 270 | |
| 271 | + /** |
|
| 272 | + * @param integer $classID |
|
| 273 | + */ |
|
| 268 | 274 | private function findClassFaction($classID) |
| 269 | 275 | { |
| 270 | 276 | $classesFactions = $this->getConfig()['classesFactions']; |
@@ -3,8 +3,6 @@ |
||
| 3 | 3 | namespace Ps2alerts\Api\Controller\Endpoint\Alerts; |
| 4 | 4 | |
| 5 | 5 | use Ps2alerts\Api\Exception\InvalidArgumentException; |
| 6 | -use Ps2alerts\Api\Repository\Metrics\CombatRepository; |
|
| 7 | -use Ps2alerts\Api\Repository\Metrics\ClassRepository; |
|
| 8 | 6 | use Psr\Http\Message\ServerRequestInterface; |
| 9 | 7 | use Psr\Http\Message\ResponseInterface; |
| 10 | 8 | |
@@ -49,23 +49,23 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | $mergedArray = []; |
| 51 | 51 | |
| 52 | - if (! $data || ! $dataArchive) { |
|
| 52 | + if (!$data || !$dataArchive) { |
|
| 53 | 53 | $sums = []; |
| 54 | 54 | foreach ($metrics as $metric) { |
| 55 | 55 | foreach ($factions as $faction) { |
| 56 | - $dbMetric = $metric . strtoupper($faction); // e.g. killsVS |
|
| 57 | - $dataMetric = $metric . strtoupper($faction); // e.g. killsVS |
|
| 56 | + $dbMetric = $metric.strtoupper($faction); // e.g. killsVS |
|
| 57 | + $dataMetric = $metric.strtoupper($faction); // e.g. killsVS |
|
| 58 | 58 | |
| 59 | 59 | // Handle teamkills inconsistency |
| 60 | 60 | if ($metric === 'teamkills') { |
| 61 | - $dbMetric = 'teamKills' . strtoupper($faction); |
|
| 61 | + $dbMetric = 'teamKills'.strtoupper($faction); |
|
| 62 | 62 | } |
| 63 | 63 | $sums[] = "SUM(factions.{$dbMetric}) AS $dataMetric"; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // Totals |
| 67 | - $dbMetric = 'total' . ucfirst($metric); // e.g. killsVS |
|
| 68 | - $dataMetric = 'total' . ucfirst($metric); // e.g. killsVS |
|
| 67 | + $dbMetric = 'total'.ucfirst($metric); // e.g. killsVS |
|
| 68 | + $dataMetric = 'total'.ucfirst($metric); // e.g. killsVS |
|
| 69 | 69 | |
| 70 | 70 | // Handle teamkills inconsistency |
| 71 | 71 | if ($metric === 'teamkills') { |
@@ -100,12 +100,12 @@ discard block |
||
| 100 | 100 | // Merge the two arrays together |
| 101 | 101 | foreach ($metrics as $metric) { |
| 102 | 102 | // Tot up totals |
| 103 | - $dbMetric = 'total' . ucfirst($metric); |
|
| 103 | + $dbMetric = 'total'.ucfirst($metric); |
|
| 104 | 104 | $mergedArray['totals'][$metric] = (int) $data[$dbMetric] + (int) $dataArchive[$dbMetric]; |
| 105 | 105 | $results['all']['totals'][$metric] += $mergedArray['totals'][$metric]; |
| 106 | 106 | |
| 107 | 107 | foreach ($factions as $faction) { |
| 108 | - $dbMetric = $metric . strtoupper($faction); |
|
| 108 | + $dbMetric = $metric.strtoupper($faction); |
|
| 109 | 109 | $mergedArray[$metric][$faction] = (int) $data[$dbMetric] + (int) $dataArchive[$dbMetric]; |
| 110 | 110 | $results['all'][$metric][$faction] += $mergedArray[$metric][$faction]; |
| 111 | 111 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | $dataArchive = $this->getRedisUtility()->checkRedis('api', 'classCombat', "{$server}-dataArchive", 'object'); |
| 149 | 149 | |
| 150 | 150 | // If data needs a pull |
| 151 | - if (! $data || ! $dataArchive) { |
|
| 151 | + if (!$data || !$dataArchive) { |
|
| 152 | 152 | $query = $this->combatRepository->newQuery('single', true); |
| 153 | 153 | $query->cols([ |
| 154 | 154 | 'classID', |
@@ -181,8 +181,8 @@ discard block |
||
| 181 | 181 | // Typecase into ints and increase totals |
| 182 | 182 | $metrics = ['kills', 'deaths', 'teamkills', 'suicides']; |
| 183 | 183 | foreach ($data as $row) { |
| 184 | - $row->classID = (int) $row->classID; |
|
| 185 | - $row->server = (int) $row->server; |
|
| 184 | + $row->classID = (int) $row->classID; |
|
| 185 | + $row->server = (int) $row->server; |
|
| 186 | 186 | $classGroup = $this->findClassGrouping($row->classID); |
| 187 | 187 | $faction = $this->findClassFaction($row->classID); |
| 188 | 188 | |
@@ -201,8 +201,8 @@ discard block |
||
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | foreach ($dataArchive as $row) { |
| 204 | - $row->classID = (int) $row->classID; |
|
| 205 | - $row->server = (int) $row->server; |
|
| 204 | + $row->classID = (int) $row->classID; |
|
| 205 | + $row->server = (int) $row->server; |
|
| 206 | 206 | |
| 207 | 207 | foreach ($metrics as $metric) { |
| 208 | 208 | $row->$metric = (int) $row->$metric; |
@@ -15,7 +15,6 @@ |
||
| 15 | 15 | /** |
| 16 | 16 | * Construct |
| 17 | 17 | * |
| 18 | - * @param League\Fractal\Manager $fractal |
|
| 19 | 18 | */ |
| 20 | 19 | public function __construct( |
| 21 | 20 | OutfitTotalRepository $repository |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | $field = $this->getField($_GET['field']); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - if (! isset($field)) { |
|
| 43 | + if (!isset($field)) { |
|
| 44 | 44 | return $this->respondWithError('Field wasn\'t provided and is required.', self::CODE_WRONG_ARGS); |
| 45 | 45 | } |
| 46 | 46 | |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | /** |
| 33 | 33 | * Get Player Leaderboard |
| 34 | 34 | * |
| 35 | - * @return \League\Fractal\Manager |
|
| 35 | + * @return \Psr\Http\Message\ResponseInterface |
|
| 36 | 36 | */ |
| 37 | 37 | public function players() |
| 38 | 38 | { |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $field = $this->getField($_GET['field']); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if (! isset($field)) { |
|
| 55 | + if (!isset($field)) { |
|
| 56 | 56 | return $this->respondWithError('Field wasn\'t provided and is required.', self::CODE_WRONG_ARGS); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | // Gets outfit details |
| 83 | 83 | for ($i = 0; $i < $count; $i++) { |
| 84 | - if (! empty($players[$i]['playerOutfit'])) { |
|
| 84 | + if (!empty($players[$i]['playerOutfit'])) { |
|
| 85 | 85 | // Gets outfit details |
| 86 | 86 | try { |
| 87 | 87 | $outfit = $this->dataEndpoint->getOutfit($players[$i]['playerOutfit']); |