Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 21 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
| 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 | class Link extends Base |
| 17 | { |
| 18 | public function loadData() |
| 19 | { |
| 20 | $data = $this->access() |
| 21 | ->fromTopic() |
| 22 | ->fetchList(); |
| 23 | $this->setItemList($this->parseData($data)); |
| 24 | } |
| 25 | |
| 26 | protected function parseData($data) |
| 27 | { |
| 28 | $itemList = new Collection(); |
| 29 | foreach ($data as $topic) { |
| 30 | foreach ($topic['links'] as $item) { |
| 31 | $itemList[$item['link']] = new Entity($item); |
| 32 | } |
| 33 | } |
| 34 | return $itemList; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * |
| 39 | * @return Collection |
| 40 | */ |
| 41 | public function fetchList() |
| 42 | { |
| 43 | return $this->getItemList(); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * |
| 48 | * @return Entity |
| 49 | */ |
| 50 | public function fetchPath($topic_path) |
| 51 | { |
| 52 | $topiclist = $this->fetchList(); |
| 53 | foreach ($topiclist as $topic) { |
| 54 | if ($topic['path'] == $topic_path) { |
| 55 | return $topic; |
| 56 | } |
| 57 | } |
| 58 | return false; |
| 59 | } |
| 60 | |
| 61 | public function readSearchResultList($query) |
| 62 | { |
| 63 | $list = $this->getItemList(); |
| 64 | $result = new Collection(); |
| 65 | foreach ($list as $link) { |
| 66 | if (false !== strpos($link['name'], $query)) { |
| 67 | $result[] = $link; |
| 68 | } |
| 69 | } |
| 70 | return $result; |
| 71 | } |
| 72 | } |