Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
24 / 24 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
Apiquota | |
100.00% |
24 / 24 |
|
100.00% |
6 / 6 |
6 | |
100.00% |
1 / 1 |
getQueryReadApiQuotaListByKey | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getQueryReadApiQuotaExpired | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
getEntityMapping | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
addConditionQuotaId | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addConditionApikey | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addConditionRoute | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace BO\Zmsdb\Query; |
4 | |
5 | /** |
6 | * @SuppressWarnings(Public) |
7 | */ |
8 | class Apiquota extends Base implements MappingInterface |
9 | { |
10 | /** |
11 | * @var String TABLE mysql table reference |
12 | */ |
13 | const TABLE = 'apiquota'; |
14 | |
15 | public static function getQueryReadApiQuotaListByKey() |
16 | { |
17 | return ' |
18 | SELECT * FROM `apiquota` WHERE `key` = :key |
19 | '; |
20 | } |
21 | |
22 | public static function getQueryReadApiQuotaExpired($dateTime) |
23 | { |
24 | $timeStamp = $dateTime->getTimestamp(); |
25 | return ' |
26 | SELECT * FROM apiquota WHERE ts <= (CASE period |
27 | WHEN "month" THEN UNIX_TIMESTAMP(DATE_ADD(FROM_UNIXTIME(' . $timeStamp . '), INTERVAL -1 MONTH)) |
28 | WHEN "week" THEN UNIX_TIMESTAMP(DATE_ADD(FROM_UNIXTIME(' . $timeStamp . '), INTERVAL -1 WEEK)) |
29 | WHEN "day" THEN UNIX_TIMESTAMP(DATE_ADD(FROM_UNIXTIME(' . $timeStamp . '), INTERVAL -1 DAY)) |
30 | WHEN "hour" THEN UNIX_TIMESTAMP(DATE_ADD(FROM_UNIXTIME(' . $timeStamp . '), INTERVAL -1 HOUR)) |
31 | WHEN "minute" THEN UNIX_TIMESTAMP(DATE_ADD(FROM_UNIXTIME(' . $timeStamp . '), INTERVAL -1 MINUTE)) |
32 | END) |
33 | '; |
34 | } |
35 | |
36 | public function getEntityMapping() |
37 | { |
38 | $mapping = [ |
39 | 'key' => 'apiquota.key', |
40 | 'route' => 'apiquota.route', |
41 | 'period' => 'apiquota.period', |
42 | 'requests' => 'apiquota.requests', |
43 | 'ts' => 'apiquota.ts' |
44 | ]; |
45 | return $mapping; |
46 | } |
47 | |
48 | public function addConditionQuotaId($quotaId) |
49 | { |
50 | $this->query->where('apiquota.quotaid', '=', $quotaId); |
51 | return $this; |
52 | } |
53 | |
54 | public function addConditionApikey($apikey) |
55 | { |
56 | $this->query->where('apiquota.key', '=', $apikey); |
57 | return $this; |
58 | } |
59 | |
60 | public function addConditionRoute($route) |
61 | { |
62 | $this->query->where('apiquota.route', '=', $route); |
63 | return $this; |
64 | } |
65 | } |