Lines 72.22% 13 / 18
Functions and Methods 75.00% 3 / 4
Classes and Traits 0.00% 0 / 1
Name Lines Functions and Methods CRAP Classes and Traits
Topic 72.22% 13 / 18 75.00% 3 / 4 9.37 0.00% 0 / 1
 parseData 100.00% 4 / 4 100.00% 1 / 1 2
 fetchList 100.00% 4 / 4 100.00% 1 / 1 2
 fetchPath 100.00% 5 / 5 100.00% 1 / 1 3
 readSearchResultList 0.00% 0 / 5 0.00% 0 / 1 2
1<?php
2
3/**
4 * @package 115Mandant
5 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
6 **/
7
8namespace BO\Zmsdldb\File;
9
10use BO\Zmsdldb\Entity\Topic as Entity;
11use BO\Zmsdldb\Collection\Topics as Collection;
12
13/**
14 * Common methods shared by access classes
15 *
16 * @extends Base<Collection, Entity>
17 */
18class Topic extends Base
19{
20    /**
21     * @return Collection
22     */
23    #[\Override]
24    protected function parseData(mixed $data)
25    {
26        $itemList = new Collection();
27        foreach ($data['data'] as $item) {
28            $itemList[$item['id']] = new Entity($item);
29        }
30        return $itemList;
31    }
32
33    /**
34     *
35     * @return Collection
36     */
37    public function fetchList()
38    {
39        $topiclist = new Collection();
40        foreach ($this->getItemList() as $item) {
41            $topiclist[$item['id']] = $item;
42        }
43        return $topiclist;
44    }
45
46    /**
47     *
48     * @return Entity|false
49     * @psalm-api
50     */
51    public function fetchPath(mixed $topic_path)
52    {
53        $topiclist = $this->fetchList();
54        foreach ($topiclist as $topic) {
55            if ($topic['path'] == $topic_path) {
56                return $topic;
57            }
58        }
59        return false;
60    }
61
62    /**
63     * @return Entity|Collection
64     * @psalm-api
65     */
66    public function readSearchResultList(mixed $querystring)
67    {
68        $topic = new Entity();
69        $topic['relation']['locations'] = $this->access()->fromLocation()->readSearchResultList($querystring);
70        $topic['relation']['services'] = $this->access()->fromService()->readSearchResultList($querystring);
71        $topic['links'] = $this->access()->fromLink()->readSearchResultList($querystring);
72        return $topic;
73    }
74}