Lines
0.00%
0 / 23
Functions and Methods
0.00%
0 / 5
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Office | 0.00% | 0 / 23 | 0.00% | 0 / 5 | 210 | 0.00% | 0 / 1 | |||
| parseData | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| getItemList | 0.00% | 0 / 17 | 0.00% | 0 / 1 | 90 | |||||
| fetchList | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| fetchId | 0.00% | 0 / 3 | 0.00% | 0 / 1 | 6 | |||||
| fetchPath | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | /** | |
| 4 | * @package ClientDldb | |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG | |
| 6 | **/ | |
| 7 | ||
| 8 | namespace BO\Zmsdldb\MySQL; | |
| 9 | ||
| 10 | use BO\Zmsdldb\MySQL\Entity\Office as Entity; | |
| 11 | use BO\Zmsdldb\MySQL\Collection\Offices as Collection; | |
| 12 | use BO\Zmsdldb\Elastic\Office as Base; | |
| 13 | ||
| 14 | /** | |
| 15 | * | |
| 16 | */ | |
| 17 | /** @psalm-api */ | |
| 18 | class Office extends Base | |
| 19 | { | |
| 20 | protected static Collection|array $officeList = []; | |
| 21 | ||
| 22 | #[\Override] | |
| 23 | protected function parseData(mixed $data): Collection | |
| 24 | { | |
| 25 | return $this->getItemList(); | |
| 26 | } | |
| 27 | ||
| 28 | #[\Override] | |
| 29 | public function getItemList(): Collection | |
| 30 | { | |
| 31 | try { | |
| 32 | if (!static::$officeList instanceof Collection) { | |
| 33 | $officeListJson = $this->access()->fromSetting()->fetchName('office'); | |
| 34 | $officeList = is_string($officeListJson) ? json_decode($officeListJson, true) : []; | |
| 35 | if (!is_array($officeList)) { | |
| 36 | $officeList = []; | |
| 37 | } | |
| 38 | ||
| 39 | static::$officeList = new Collection(); | |
| 40 | foreach ($officeList as $item) { | |
| 41 | if (!is_array($item)) { | |
| 42 | continue; | |
| 43 | } | |
| 44 | $office = new Entity($item); | |
| 45 | if (isset($item['path'])) { | |
| 46 | static::$officeList[$item['path']] = $office; | |
| 47 | } | |
| 48 | if (isset($item['plural'])) { | |
| 49 | static::$officeList[$item['plural']] = $office; | |
| 50 | } | |
| 51 | } | |
| 52 | #echo '<pre>' . htmlspecialchars(print_r((static::$officeList),1)) . '</pre>';exit; | |
| 53 | } | |
| 54 | return static::$officeList; | |
| 55 | } catch (\Exception $e) { | |
| 56 | throw $e; | |
| 57 | } | |
| 58 | } | |
| 59 | ||
| 60 | #[\Override] | |
| 61 | public function fetchList(): Collection | |
| 62 | { | |
| 63 | return $this->getItemList(); | |
| 64 | } | |
| 65 | ||
| 66 | #[\Override] | |
| 67 | public function fetchId(mixed $itemId): Entity|false | |
| 68 | { | |
| 69 | $list = $this->fetchList(); | |
| 70 | $office = $list[$itemId] ?? false; | |
| 71 | return $office instanceof Entity ? $office : false; | |
| 72 | } | |
| 73 | ||
| 74 | #[\Override] | |
| 75 | public function fetchPath(mixed $itemId): Entity|false | |
| 76 | { | |
| 77 | return $this->fetchId($itemId); | |
| 78 | } | |
| 79 | } |