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