@@ -2,11 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Ps2alerts\Api\Controller\Endpoint\Alerts; |
| 4 | 4 | |
| 5 | -use League\Fractal\Manager; |
|
| 6 | 5 | use Ps2alerts\Api\Controller\Endpoint\Alerts\AlertEndpointController; |
| 7 | 6 | use Ps2alerts\Api\Exception\InvalidArgumentException; |
| 8 | -use Ps2alerts\Api\Repository\Metrics\CombatRepository; |
|
| 9 | -use Ps2alerts\Api\Repository\Metrics\ClassRepository; |
|
| 10 | 7 | use Psr\Http\Message\ServerRequestInterface; |
| 11 | 8 | use Psr\Http\Message\ResponseInterface; |
| 12 | 9 | |
@@ -49,23 +49,23 @@ discard block |
||
| 49 | 49 | $data = $this->checkRedis('api', 'combatTotals', "{$server}-data"); |
| 50 | 50 | $dataArchive = $this->checkRedis('api', 'combatTotals', "{$server}-dataArchive"); |
| 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->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; |
@@ -5,7 +5,6 @@ |
||
| 5 | 5 | use League\Fractal\Manager; |
| 6 | 6 | use Ps2alerts\Api\Controller\Endpoint\AbstractEndpointController; |
| 7 | 7 | use Ps2alerts\Api\Repository\AlertRepository; |
| 8 | -use Ps2alerts\Api\Transformer\AlertTotalTransformer; |
|
| 9 | 8 | use Ps2alerts\Api\Transformer\AlertTransformer; |
| 10 | 9 | use Psr\Http\Message\ServerRequestInterface; |
| 11 | 10 | use Psr\Http\Message\ResponseInterface; |
@@ -103,11 +103,11 @@ discard block |
||
| 103 | 103 | $limit = (int) $_GET['limit']; |
| 104 | 104 | |
| 105 | 105 | // Set defaults if not supplied |
| 106 | - if (empty($offset) || ! is_numeric($offset)) { |
|
| 106 | + if (empty($offset) || !is_numeric($offset)) { |
|
| 107 | 107 | $offset = 0; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if (empty($limit) || ! is_numeric($limit)) { |
|
| 110 | + if (empty($limit) || !is_numeric($limit)) { |
|
| 111 | 111 | $limit = 50; |
| 112 | 112 | } |
| 113 | 113 | |
@@ -173,11 +173,11 @@ discard block |
||
| 173 | 173 | $limit = (int) $_GET['limit']; |
| 174 | 174 | |
| 175 | 175 | // Set defaults if not supplied |
| 176 | - if (empty($offset) || ! is_numeric($offset)) { |
|
| 176 | + if (empty($offset) || !is_numeric($offset)) { |
|
| 177 | 177 | $offset = 0; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - if (empty($limit) || ! is_numeric($limit)) { |
|
| 180 | + if (empty($limit) || !is_numeric($limit)) { |
|
| 181 | 181 | $limit = 50; |
| 182 | 182 | } |
| 183 | 183 | |
@@ -5,10 +5,7 @@ |
||
| 5 | 5 | use League\Fractal\Manager; |
| 6 | 6 | use Ps2alerts\Api\Controller\Endpoint\AbstractEndpointController; |
| 7 | 7 | use Ps2alerts\Api\Repository\AlertRepository; |
| 8 | -use Ps2alerts\Api\Transformer\AlertTotalTransformer; |
|
| 9 | 8 | use Ps2alerts\Api\Transformer\AlertTransformer; |
| 10 | -use Psr\Http\Message\ServerRequestInterface; |
|
| 11 | -use Psr\Http\Message\ResponseInterface; |
|
| 12 | 9 | |
| 13 | 10 | class ContextualDataEndpointController extends AbstractEndpointController |
| 14 | 11 | { |
@@ -22,6 +22,6 @@ |
||
| 22 | 22 | public function __construct( |
| 23 | 23 | Manager $fractal |
| 24 | 24 | ) { |
| 25 | - $this->fractal = $fractal; |
|
| 25 | + $this->fractal = $fractal; |
|
| 26 | 26 | } |
| 27 | 27 | } |
@@ -2,10 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Ps2alerts\Api\Controller\Endpoint\Leaderboards; |
| 4 | 4 | |
| 5 | -use League\Fractal\Manager; |
|
| 6 | 5 | use Ps2alerts\Api\Controller\Endpoint\AbstractEndpointController; |
| 7 | -use Ps2alerts\Api\Repository\Metrics\OutfitTotalRepository; |
|
| 8 | -use Ps2alerts\Api\Repository\Metrics\PlayerTotalRepository; |
|
| 9 | 6 | use Psr\Http\Message\ServerRequestInterface; |
| 10 | 7 | use Psr\Http\Message\ResponseInterface; |
| 11 | 8 | |
@@ -83,7 +83,7 @@ |
||
| 83 | 83 | |
| 84 | 84 | $data = []; |
| 85 | 85 | |
| 86 | - foreach($config['servers'] as $server) { |
|
| 86 | + foreach ($config['servers'] as $server) { |
|
| 87 | 87 | $key = "ps2alerts:api:leaderboards:status:{$server}"; |
| 88 | 88 | |
| 89 | 89 | if ($redis->exists($key)) { |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use League\Fractal\Manager; |
| 6 | 6 | use Ps2alerts\Api\Controller\Endpoint\AbstractEndpointController; |
| 7 | -use Ps2alerts\Api\Exception\InvalidArgumentException; |
|
| 8 | 7 | use Ps2alerts\Api\Repository\Metrics\OutfitTotalRepository; |
| 9 | 8 | use Ps2alerts\Api\Repository\Metrics\PlayerTotalRepository; |
| 10 | 9 | use Ps2alerts\Api\Transformer\Search\OutfitSearchTransformer; |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | if ($this->parsePlayerName($args['term'], $response)) { |
| 53 | 53 | $players = $this->searchForPlayer($args['term']); |
| 54 | 54 | |
| 55 | - if (! empty($players)) { |
|
| 55 | + if (!empty($players)) { |
|
| 56 | 56 | return $this->respond( |
| 57 | 57 | 'collection', |
| 58 | 58 | $players, |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | if ($this->parseOutfitName($name, $response)) { |
| 82 | 82 | $outfits = $this->searchForOutfit($name); |
| 83 | 83 | |
| 84 | - if (! empty($outfits)) { |
|
| 84 | + if (!empty($outfits)) { |
|
| 85 | 85 | return $this->respond( |
| 86 | 86 | 'collection', |
| 87 | 87 | $outfits, |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | return $this->errorWrongArgs('Player ID cannot be longer than 19 characters.'); |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - if (! is_numeric($id)) { |
|
| 202 | + if (!is_numeric($id)) { |
|
| 203 | 203 | return $this->errorWrongArgs('Player ID must be numeric.'); |
| 204 | 204 | } |
| 205 | 205 | |
@@ -14,7 +14,6 @@ |
||
| 14 | 14 | use Ps2alerts\Api\Repository\Metrics\VehicleTotalRepository; |
| 15 | 15 | use Ps2alerts\Api\Repository\Metrics\WeaponTotalRepository; |
| 16 | 16 | use Ps2alerts\Api\Repository\Metrics\XpRepository; |
| 17 | - |
|
| 18 | 17 | use Ps2alerts\Api\Transformer\Metrics\ClassTransformer; |
| 19 | 18 | use Ps2alerts\Api\Transformer\Metrics\CombatHistoryTransformer; |
| 20 | 19 | use Ps2alerts\Api\Transformer\Metrics\CombatTransformer; |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | $obj = [ |
| 19 | 19 | 'id' => (string) $data->outfit_id, // Bigint |
| 20 | 20 | 'name' => (string) $data->name, |
| 21 | - 'tag' => (! empty($data->alias)) ? (string) $data->alias : null, |
|
| 21 | + 'tag' => (!empty($data->alias)) ? (string) $data->alias : null, |
|
| 22 | 22 | 'faction' => (int) $data->leader->faction_id, |
| 23 | 23 | 'count' => (int) $data->member_count, |
| 24 | 24 | 'leader' => (string) $data->leader_character_id, |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | public function transform($data) |
| 17 | 17 | { |
| 18 | - if (! isset($data['playerOutfit'])) { |
|
| 18 | + if (!isset($data['playerOutfit'])) { |
|
| 19 | 19 | $outfit = null; |
| 20 | 20 | } else { |
| 21 | 21 | $outfit = $data['playerOutfit']; |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | $key = "ps2alerts:api:profiles:outfit:players:{$data['outfitID']}"; |
| 192 | 192 | |
| 193 | 193 | // If we have this cached already |
| 194 | - if (! empty($redis->exists($key))) { |
|
| 194 | + if (!empty($redis->exists($key))) { |
|
| 195 | 195 | return json_decode($redis->get($key), true); |
| 196 | 196 | } |
| 197 | 197 | |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | $key = "ps2alerts:api:profiles:outfit:census:members:{$data['outfitID']}:{$offset}"; |
| 228 | 228 | |
| 229 | 229 | // If we have this cached already |
| 230 | - if (! empty($redis->exists($key))) { |
|
| 230 | + if (!empty($redis->exists($key))) { |
|
| 231 | 231 | return json_decode($redis->get($key)); |
| 232 | 232 | } |
| 233 | 233 | |