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