@@ -13,7 +13,7 @@ |
||
13 | 13 | /** |
14 | 14 | * Returns a single entry |
15 | 15 | * |
16 | - * @param Symfony\Component\HttpFoundation\Request $request |
|
16 | + * @param Request $request |
|
17 | 17 | * @param array $args |
18 | 18 | * |
19 | 19 | * @return \League\Route\Http\JsonResponse |
@@ -4,7 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use League\Route\Http\JsonResponse as Response; |
6 | 6 | use Ps2alerts\Api\Controller\EndpointBaseController; |
7 | -use Ps2alerts\Api\QueryObjects\QueryObject; |
|
8 | 7 | use Ps2alerts\Api\Loader\ResultLoader; |
9 | 8 | use Symfony\Component\HttpFoundation\Request; |
10 | 9 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | /** |
13 | 13 | * Construct |
14 | 14 | * |
15 | - * @param \Ps2alerts\Api\Loader\Metrics\OutfitTotalsStatisticsLoader $loader |
|
15 | + * @param OutfitTotalsStatisticsLoader $loader |
|
16 | 16 | */ |
17 | 17 | public function __construct(OutfitTotalsStatisticsLoader $loader) |
18 | 18 | { |
@@ -23,7 +23,6 @@ discard block |
||
23 | 23 | * Returns top X entries |
24 | 24 | * |
25 | 25 | * @param \Symfony\Component\HttpFoundation\Request $request |
26 | - * @param array $args |
|
27 | 26 | * |
28 | 27 | * @return \League\Route\Http\JsonResponse |
29 | 28 | */ |
@@ -12,7 +12,7 @@ |
||
12 | 12 | /** |
13 | 13 | * Construct |
14 | 14 | * |
15 | - * @param \Ps2alerts\Api\Loader\Metrics\PlayerStatisticsLoader $loader |
|
15 | + * @param PlayerStatisticsLoader $loader |
|
16 | 16 | */ |
17 | 17 | public function __construct(PlayerStatisticsLoader $loader) |
18 | 18 | { |
@@ -16,7 +16,7 @@ |
||
16 | 16 | /** |
17 | 17 | * Construct |
18 | 18 | * |
19 | - * @param \Ps2alerts\Api\Repository\Metrics\OutfitTotalsRepository $repository |
|
19 | + * @param OutfitTotalsRepository $repository |
|
20 | 20 | */ |
21 | 21 | public function __construct(OutfitTotalsRepository $repository) |
22 | 22 | { |
@@ -4,7 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use League\Route\Http\JsonResponse as Response; |
6 | 6 | use Ps2alerts\Api\Controller\EndpointBaseController; |
7 | -use Ps2alerts\Api\QueryObjects\QueryObject; |
|
8 | 7 | use Ps2alerts\Api\Loader\ResultLoader; |
9 | 8 | use Symfony\Component\HttpFoundation\Request; |
10 | 9 |
@@ -91,6 +91,9 @@ |
||
91 | 91 | ); |
92 | 92 | } |
93 | 93 | |
94 | + /** |
|
95 | + * @param string $field |
|
96 | + */ |
|
94 | 97 | public function validatePostVars($field, $value) |
95 | 98 | { |
96 | 99 | if ($field === 'metric' && ! empty($value)) { |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | $queryObject = new QueryObject; |
33 | 33 | |
34 | 34 | // Build based on metric alone (order by playerKills for example) |
35 | - if (! empty($post['metric'] && empty($post['value'])) |
|
35 | + if (!empty($post['metric'] && empty($post['value'])) |
|
36 | 36 | && $this->validatePostVars('metric', $post['metric']) === true |
37 | 37 | ) { |
38 | - $direction = (! empty($post['direction']) ? $post['direction'] : 'desc'); |
|
38 | + $direction = (!empty($post['direction']) ? $post['direction'] : 'desc'); |
|
39 | 39 | |
40 | 40 | $queryObject->setOrderBy($post['metric']); |
41 | 41 | $queryObject->setOrderByDirection($direction); |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | // Build based on metric and a value (such as order by playerKills by server) |
47 | - if (! empty($post['value']) |
|
48 | - && ! empty($post['metric']) |
|
47 | + if (!empty($post['value']) |
|
48 | + && !empty($post['metric']) |
|
49 | 49 | && $this->validatePostVars('metric', $post['metric']) === true |
50 | 50 | ) { |
51 | - $op = (! empty($post['operator']) ? $post['operator'] : '='); |
|
51 | + $op = (!empty($post['operator']) ? $post['operator'] : '='); |
|
52 | 52 | |
53 | 53 | $queryObject->addWhere([ |
54 | 54 | 'col' => $post['metric'], |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | 'value' => $post['value'] |
57 | 57 | ]); |
58 | 58 | |
59 | - $direction = (! empty($post['direction']) ? $post['direction'] : 'desc'); |
|
59 | + $direction = (!empty($post['direction']) ? $post['direction'] : 'desc'); |
|
60 | 60 | |
61 | 61 | $queryObject->setOrderBy($post['metric']); |
62 | 62 | $queryObject->setOrderByDirection($direction); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $redisKey .= ":{$post['metric']}{$op}{$post['value']}-{$direction}"; |
65 | 65 | } |
66 | 66 | |
67 | - if (! empty($post['limit'])) { |
|
67 | + if (!empty($post['limit'])) { |
|
68 | 68 | $post['limit'] = intval($post['limit']); |
69 | 69 | |
70 | 70 | // Hard encode a 50 limit |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | |
94 | 94 | public function validatePostVars($field, $value) |
95 | 95 | { |
96 | - if ($field === 'metric' && ! empty($value)) { |
|
96 | + if ($field === 'metric' && !empty($value)) { |
|
97 | 97 | switch ($value) { |
98 | 98 | case 'playerKills': |
99 | 99 | case 'playerDeaths': |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | 'value' => date('U', strtotime('-48 hours')) |
42 | 42 | ]); |
43 | 43 | |
44 | - if (! empty($args['serverID'])) { |
|
44 | + if (!empty($args['serverID'])) { |
|
45 | 45 | $redisKey .= ":{$args['serverID']}"; |
46 | 46 | $queryObject->addWhere([ |
47 | 47 | 'col' => 'ResultServer', |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | ]); |
50 | 50 | } |
51 | 51 | |
52 | - if (! empty($args['limit'])) { |
|
52 | + if (!empty($args['limit'])) { |
|
53 | 53 | if ($args['limit'] > 50) { |
54 | 54 | $args['limit'] = 50; |
55 | 55 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | 'value' => 1 |
82 | 82 | ]); |
83 | 83 | |
84 | - if (! empty($args['serverID'])) { |
|
84 | + if (!empty($args['serverID'])) { |
|
85 | 85 | $queryObject->addWhere([ |
86 | 86 | 'col' => 'ResultServer', |
87 | 87 | 'value' => $args['serverID'] |
@@ -149,7 +149,7 @@ |
||
149 | 149 | * Takes common requests and appends them to the query object. Any other |
150 | 150 | * special requirements will be handled after |
151 | 151 | * |
152 | - * @param Ps2alerts\Api\QueryObjects\QueryObject $queryObject |
|
152 | + * @param QueryObject $queryObject |
|
153 | 153 | * @param array $post |
154 | 154 | * |
155 | 155 | * @return Ps2alerts\Api\QueryObjects\QueryObject |
@@ -75,33 +75,33 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function appendRedisKey($post, $redisKey) |
77 | 77 | { |
78 | - if (! empty($post['selects'])) { |
|
78 | + if (!empty($post['selects'])) { |
|
79 | 79 | $whereMD5 = md5($post['selects']); |
80 | 80 | $redisKey .= "/select{$whereMD5}"; |
81 | 81 | } |
82 | 82 | |
83 | - if (! empty($post['wheres'])) { |
|
83 | + if (!empty($post['wheres'])) { |
|
84 | 84 | $whereMD5 = md5($post['wheres']); |
85 | 85 | $redisKey .= "/where{$whereMD5}"; |
86 | 86 | } |
87 | 87 | |
88 | - if (! empty($post['whereIns'])) { |
|
88 | + if (!empty($post['whereIns'])) { |
|
89 | 89 | $whereInMD5 = md5($post['whereIns']); |
90 | 90 | $redisKey .= "/whereIn{$whereInMD5}"; |
91 | 91 | } |
92 | 92 | |
93 | - if (! empty($post['orderBy'])) { |
|
93 | + if (!empty($post['orderBy'])) { |
|
94 | 94 | $orderMD5 = md5($post['orderBy']); |
95 | 95 | $redisKey .= "/order{$orderMD5}"; |
96 | 96 | } |
97 | - if (! empty($post['limit'])) { |
|
97 | + if (!empty($post['limit'])) { |
|
98 | 98 | // Enforce a max limit |
99 | 99 | if ($post['limit'] > 50) { |
100 | 100 | $post['limit'] = 50; |
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | - if (empty($post['limit']) || ! isset($post['limit'])) { |
|
104 | + if (empty($post['limit']) || !isset($post['limit'])) { |
|
105 | 105 | $post['limit'] = 10; |
106 | 106 | } |
107 | 107 | |
@@ -119,20 +119,20 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function processPostVars($post) |
121 | 121 | { |
122 | - if (! empty($post['wheres'])) { |
|
122 | + if (!empty($post['wheres'])) { |
|
123 | 123 | $return['wheres'] = json_decode($post['wheres'], true); |
124 | 124 | $this->getLogDriver()->addDebug(json_encode($return['wheres'])); |
125 | 125 | } |
126 | 126 | |
127 | - if (! empty($post['whereIns'])) { |
|
127 | + if (!empty($post['whereIns'])) { |
|
128 | 128 | $return['whereIns'] = json_decode($post['whereIns'], true); |
129 | 129 | } |
130 | 130 | |
131 | - if (! empty($post['orderBy'])) { |
|
131 | + if (!empty($post['orderBy'])) { |
|
132 | 132 | $return['orderBy'] = json_decode($post['orderBy'], true); |
133 | 133 | } |
134 | 134 | |
135 | - if (empty($post['limit']) || ! isset($post['limit'])) { |
|
135 | + if (empty($post['limit']) || !isset($post['limit'])) { |
|
136 | 136 | $post['limit'] = 10; |
137 | 137 | } |
138 | 138 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function setupQueryObject($queryObject, $post) |
158 | 158 | { |
159 | - if (! empty($post['wheres'])) { |
|
159 | + if (!empty($post['wheres'])) { |
|
160 | 160 | foreach ($post['wheres'] as $key => $value) { |
161 | 161 | $queryObject->addWhere([ |
162 | 162 | 'col' => $key, |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | - if (! empty($post['whereIns'])) { |
|
168 | + if (!empty($post['whereIns'])) { |
|
169 | 169 | foreach ($post['whereIns'] as $key => $value) { |
170 | 170 | // Escape strings manually, incase of player IDs etc |
171 | 171 | foreach ($value as $i => $val) { |
@@ -181,16 +181,16 @@ discard block |
||
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | - if (! empty($post['orderBy'])) { |
|
184 | + if (!empty($post['orderBy'])) { |
|
185 | 185 | $queryObject->setOrderBy(array_keys($post['orderBy'])[0]); |
186 | 186 | $queryObject->setOrderByDirection(array_values($post['orderBy'])[0]); |
187 | 187 | } |
188 | 188 | |
189 | - if (! empty($post['limit'])) { |
|
189 | + if (!empty($post['limit'])) { |
|
190 | 190 | $queryObject->setLimit($post['limit']); |
191 | 191 | } |
192 | 192 | |
193 | - if (! empty($this->getFlags())) { |
|
193 | + if (!empty($this->getFlags())) { |
|
194 | 194 | // If there are some funky things we have to do, set them. |
195 | 195 | $queryObject->setFlags($this->getFlags()); |
196 | 196 | } |
@@ -54,7 +54,7 @@ |
||
54 | 54 | * in the array and added to. |
55 | 55 | * e.g. $queryObject->addSelect('COUNT(ResultID) AS COUNT'); |
56 | 56 | * |
57 | - * @param string $string |
|
57 | + * @param string $array |
|
58 | 58 | */ |
59 | 59 | public function addSelect($array) |
60 | 60 | { |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function setOrderBy($string) |
120 | 120 | { |
121 | - if (! empty($string)) { |
|
121 | + if (!empty($string)) { |
|
122 | 122 | $this->orderBy = $string; |
123 | 123 | } |
124 | 124 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | */ |
141 | 141 | public function setOrderByDirection($string) |
142 | 142 | { |
143 | - if (! empty($string)) { |
|
143 | + if (!empty($string)) { |
|
144 | 144 | $this->orderByDirection = $string; |
145 | 145 | } |
146 | 146 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | */ |
163 | 163 | public function setDimension($string) |
164 | 164 | { |
165 | - if (! empty($string)) { |
|
165 | + if (!empty($string)) { |
|
166 | 166 | $this->dimension = $string; |
167 | 167 | } |
168 | 168 | } |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function setLimit($limit) |
186 | 186 | { |
187 | - if (! empty($limit) && is_numeric($limit)) { |
|
187 | + if (!empty($limit) && is_numeric($limit)) { |
|
188 | 188 | $this->limit = $limit; |
189 | 189 | } |
190 | 190 | } |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | public function setFlags($flags) |
208 | 208 | { |
209 | - if (! empty($flags)) { |
|
209 | + if (!empty($flags)) { |
|
210 | 210 | $this->flags = $flags; |
211 | 211 | } |
212 | 212 | } |