Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
27 / 27 |
|
100.00% |
7 / 7 |
CRAP | |
100.00% |
1 / 1 |
Ticketprinter | |
100.00% |
27 / 27 |
|
100.00% |
7 / 7 |
9 | |
100.00% |
1 / 1 |
getOrganisationIdByHash | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getEntityMapping | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
addConditionTicketprinterId | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addConditionOrganisationId | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addConditionHash | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addConditionDeleteInterval | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
reverseEntityMapping | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
3 |
1 | <?php |
2 | |
3 | namespace BO\Zmsdb\Query; |
4 | |
5 | class Ticketprinter extends Base implements MappingInterface |
6 | { |
7 | /** |
8 | * @var String TABLE mysql table reference |
9 | */ |
10 | const TABLE = 'kiosk'; |
11 | |
12 | const PRIMARY = 'hash'; |
13 | |
14 | /** |
15 | * No resolving required here |
16 | */ |
17 | protected $resolveLevel = 0; |
18 | |
19 | public function getOrganisationIdByHash() |
20 | { |
21 | return ' |
22 | SELECT organisationsid |
23 | FROM `kiosk` ticketprinter |
24 | WHERE ticketprinter.`cookiecode` = :hash'; |
25 | } |
26 | |
27 | public function getEntityMapping() |
28 | { |
29 | return [ |
30 | 'enabled' => self::expression('CAST(`ticketprinter`.`zugelassen` AS SIGNED)'), |
31 | 'hash' => 'ticketprinter.cookiecode', |
32 | 'id' => 'ticketprinter.kioskid', |
33 | 'lastUpdate' => 'ticketprinter.timestamp', |
34 | 'name' => 'ticketprinter.name' |
35 | ]; |
36 | } |
37 | |
38 | public function addConditionTicketprinterId($ticketprinterId) |
39 | { |
40 | $this->query->where('ticketprinter.kioskid', '=', $ticketprinterId); |
41 | return $this; |
42 | } |
43 | |
44 | public function addConditionOrganisationId($organisationId) |
45 | { |
46 | $this->query->where('ticketprinter.organisationsid', '=', $organisationId); |
47 | return $this; |
48 | } |
49 | |
50 | public function addConditionHash($hash) |
51 | { |
52 | $this->query->where('ticketprinter.cookiecode', '=', $hash); |
53 | return $this; |
54 | } |
55 | |
56 | public function addConditionDeleteInterval($expirationDate) |
57 | { |
58 | $this->query->where('ticketprinter.timestamp', '<=', $expirationDate->getTimestamp()); |
59 | return $this; |
60 | } |
61 | |
62 | public function reverseEntityMapping(\BO\Zmsentities\Ticketprinter $entity, $organisationId) |
63 | { |
64 | $data = array(); |
65 | $data['organisationsid'] = $organisationId; |
66 | $data['zugelassen'] = ($entity->isEnabled()) ? 1 : 0; |
67 | $data['cookiecode'] = $entity->getId(); |
68 | $data['timestamp'] = time(); |
69 | $data['name'] = $entity->toProperty()->name->get(); |
70 | $data = array_filter($data, function ($value) { |
71 | return ($value !== null && $value !== false); |
72 | }); |
73 | return $data; |
74 | } |
75 | } |