Lines
0.00%
0 / 21
Functions and Methods
0.00%
0 / 5
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Link | 0.00% | 0 / 21 | 0.00% | 0 / 5 | 132 | 0.00% | 0 / 1 | |||
| loadData | 0.00% | 0 / 4 | 0.00% | 0 / 1 | 2 | |||||
| parseData | 0.00% | 0 / 5 | 0.00% | 0 / 1 | 12 | |||||
| fetchList | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| fetchPath | 0.00% | 0 / 5 | 0.00% | 0 / 1 | 12 | |||||
| readSearchResultList | 0.00% | 0 / 6 | 0.00% | 0 / 1 | 12 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | /** | |
| 4 | * @package 115Mandant | |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG | |
| 6 | **/ | |
| 7 | ||
| 8 | namespace BO\Zmsdldb\File; | |
| 9 | ||
| 10 | use BO\Zmsdldb\Entity\Link as Entity; | |
| 11 | use BO\Zmsdldb\Collection\Links as Collection; | |
| 12 | ||
| 13 | /** | |
| 14 | * Common methods shared by access classes | |
| 15 | * | |
| 16 | * @extends Base<Collection, Entity> | |
| 17 | */ | |
| 18 | class Link extends Base | |
| 19 | { | |
| 20 | /** | |
| 21 | * @return void | |
| 22 | */ | |
| 23 | #[\Override] | |
| 24 | public function loadData() | |
| 25 | { | |
| 26 | $data = $this->access() | |
| 27 | ->fromTopic() | |
| 28 | ->fetchList(); | |
| 29 | /** @psalm-suppress InvalidArgument */ | |
| 30 | $this->setItemList($this->parseData($data)); | |
| 31 | } | |
| 32 | ||
| 33 | /** | |
| 34 | * @return Collection | |
| 35 | */ | |
| 36 | #[\Override] | |
| 37 | protected function parseData(mixed $data) | |
| 38 | { | |
| 39 | $itemList = new Collection(); | |
| 40 | foreach ($data as $topic) { | |
| 41 | foreach ($topic['links'] as $item) { | |
| 42 | $itemList[$item['link']] = new Entity($item); | |
| 43 | } | |
| 44 | } | |
| 45 | return $itemList; | |
| 46 | } | |
| 47 | ||
| 48 | /** | |
| 49 | * | |
| 50 | * @return Collection | |
| 51 | */ | |
| 52 | public function fetchList() | |
| 53 | { | |
| 54 | return $this->getItemList(); | |
| 55 | } | |
| 56 | ||
| 57 | /** | |
| 58 | * | |
| 59 | * @return Entity|false | |
| 60 | * @psalm-api | |
| 61 | */ | |
| 62 | public function fetchPath(mixed $topic_path) | |
| 63 | { | |
| 64 | $topiclist = $this->fetchList(); | |
| 65 | foreach ($topiclist as $topic) { | |
| 66 | if ($topic['path'] == $topic_path) { | |
| 67 | return $topic; | |
| 68 | } | |
| 69 | } | |
| 70 | return false; | |
| 71 | } | |
| 72 | ||
| 73 | /** | |
| 74 | * @psalm-api | |
| 75 | * | |
| 76 | * @return Collection | |
| 77 | */ | |
| 78 | public function readSearchResultList(mixed $query) | |
| 79 | { | |
| 80 | $list = $this->getItemList(); | |
| 81 | $result = new Collection(); | |
| 82 | foreach ($list as $link) { | |
| 83 | if (false !== strpos($link['name'], $query)) { | |
| 84 | $result->append($link); | |
| 85 | } | |
| 86 | } | |
| 87 | return $result; | |
| 88 | } | |
| 89 | } |