Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
39 / 39 |
|
100.00% |
10 / 10 |
CRAP | |
100.00% |
1 / 1 |
DayOff | |
100.00% |
39 / 39 |
|
100.00% |
10 / 10 |
10 | |
100.00% |
1 / 1 |
getEntityMapping | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
addConditionYear | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addConditionDate | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addConditionName | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addConditionCommon | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addConditionDayOffId | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addConditionScopeId | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
addConditionDepartmentId | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addConditionDayoffDeleteInterval | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
postProcess | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace BO\Zmsdb\Query; |
4 | |
5 | class DayOff extends Base implements MappingInterface |
6 | { |
7 | /** |
8 | * @var String TABLE mysql table reference |
9 | */ |
10 | const TABLE = 'feiertage'; |
11 | |
12 | /** |
13 | * No resolving required here |
14 | */ |
15 | protected $resolveLevel = 0; |
16 | |
17 | public function getEntityMapping() |
18 | { |
19 | return [ |
20 | 'id' => 'dayOff.FeiertagID', |
21 | 'date' => 'dayOff.Datum', |
22 | 'lastChange' => 'dayOff.updateTimestamp', |
23 | 'name' => 'dayOff.Feiertag' |
24 | ]; |
25 | } |
26 | |
27 | public function addConditionYear($year) |
28 | { |
29 | $this->query->where(self::expression('YEAR(`dayOff`.`Datum`)'), '=', $year); |
30 | return $this; |
31 | } |
32 | |
33 | public function addConditionDate($date) |
34 | { |
35 | $this->query->where('dayOff`.`Datum', '=', $date); |
36 | return $this; |
37 | } |
38 | |
39 | public function addConditionName($name) |
40 | { |
41 | $this->query->where('dayOff`.`Feiertag', '=', $name); |
42 | return $this; |
43 | } |
44 | |
45 | public function addConditionCommon() |
46 | { |
47 | $this->query->where('dayOff.BehoerdenID', '=', 0); |
48 | return $this; |
49 | } |
50 | |
51 | public function addConditionDayOffId($itemId) |
52 | { |
53 | $this->query->where('dayOff.FeiertagID', '=', $itemId); |
54 | return $this; |
55 | } |
56 | |
57 | public function addConditionScopeId($scopeId) |
58 | { |
59 | $this->leftJoin( |
60 | new Alias('standort', 'scope_dayoff'), |
61 | 'scope_dayoff.BehoerdenID', |
62 | '=', |
63 | 'dayOff.BehoerdenID' |
64 | ); |
65 | $this->query->where('scope_dayoff.StandortID', '=', $scopeId); |
66 | return $this; |
67 | } |
68 | |
69 | public function addConditionDepartmentId($departmentId) |
70 | { |
71 | $this->query->where('dayOff.BehoerdenID', '=', $departmentId); |
72 | return $this; |
73 | } |
74 | |
75 | public function addConditionDayoffDeleteInterval($deleteInSeconds) |
76 | { |
77 | $this->query->where( |
78 | self::expression( |
79 | 'UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`dayOff`.`Datum`)' |
80 | ), |
81 | '>=', |
82 | $deleteInSeconds |
83 | ); |
84 | return $this; |
85 | } |
86 | |
87 | public function postProcess($data) |
88 | { |
89 | $data[$this->getPrefixed("date")] = (new \DateTime($data[$this->getPrefixed("date")]))->getTimestamp(); |
90 | $data[$this->getPrefixed("lastChange")] = |
91 | (new \DateTime($data[$this->getPrefixed("lastChange")] . \BO\Zmsdb\Connection\Select::$connectionTimezone)) |
92 | ->getTimestamp(); |
93 | return $data; |
94 | } |
95 | } |