Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
72.22% covered (warning)
72.22%
13 / 18
75.00% covered (warning)
75.00%
3 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
Topic
72.22% covered (warning)
72.22%
13 / 18
75.00% covered (warning)
75.00%
3 / 4
9.37
0.00% covered (danger)
0.00%
0 / 1
 parseData
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
 fetchList
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
 fetchPath
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
3
 readSearchResultList
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
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 */
16class Topic extends Base
17{
18    /**
19     * @return Collection
20     */
21    #[\Override]
22    protected function parseData($data)
23    {
24        $itemList = new Collection();
25        foreach ($data['data'] as $item) {
26            $itemList[$item['id']] = new Entity($item);
27        }
28        return $itemList;
29    }
30
31    /**
32     *
33     * @return Collection
34     */
35    public function fetchList()
36    {
37        $topiclist = new Collection();
38        foreach ($this->getItemList() as $item) {
39            $topiclist[$item['id']] = $item;
40        }
41        return $topiclist;
42    }
43
44    /**
45     *
46     * @return Entity|false
47     * @psalm-api
48     */
49    public function fetchPath($topic_path)
50    {
51        $topiclist = $this->fetchList();
52        foreach ($topiclist as $topic) {
53            if ($topic['path'] == $topic_path) {
54                return $topic;
55            }
56        }
57        return false;
58    }
59
60    /**
61     * @return Entity
62     * @psalm-api
63     */
64    public function readSearchResultList($querystring)
65    {
66        $topic = new Entity();
67        $topic['relation']['locations'] = $this->access()->fromLocation()->readSearchResultList($querystring);
68        $topic['relation']['services'] = $this->access()->fromService()->readSearchResultList($querystring);
69        $topic['links'] = $this->access()->fromLink()->readSearchResultList($querystring);
70        return $topic;
71    }
72}