Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
18.18% covered (danger)
18.18%
4 / 22
25.00% covered (danger)
25.00%
1 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
Topic
18.18% covered (danger)
18.18%
4 / 22
25.00% covered (danger)
25.00%
1 / 4
90.87
0.00% covered (danger)
0.00%
0 / 1
 getServiceIds
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
 isLinked
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
6
 getServiceLocationLinkList
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
12
 getParentId
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
30
1<?php
2
3/**
4 * @package Zmsdldb
5 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
6 **/
7
8namespace BO\Zmsdldb\Entity;
9
10/**
11 * Helper for topics export
12 */
13class Topic extends Base
14{
15    public function getServiceIds(): array
16    {
17        $serviceIds = array();
18        foreach ($this['relation']['services'] as $service) {
19            $serviceIds[] = $service['id'];
20        }
21        return $serviceIds;
22    }
23
24    /**
25     * @psalm-api
26     */
27    public function isLinked(): bool
28    {
29        /** @psalm-suppress RiskyTruthyFalsyComparison */
30        return ($this['relation']['navi'] || static::subcount($this['relation']['navi']));
31    }
32
33    /**
34     * @psalm-api
35     */
36    public function getServiceLocationLinkList(): \BO\Zmsdldb\Collection\Base
37    {
38        $list = new \BO\Zmsdldb\Collection\Base();
39        $items = array(
40            $this['relation']['services'],
41            $this['relation']['locations'],
42            $this['links']
43        );
44        foreach ($items as $item) {
45            foreach ($item as $entity) {
46                $list->append($entity);
47            }
48        }
49        return $list;
50    }
51
52    /** @psalm-api */
53    public function getParentId(): mixed
54    {
55        if (count($this['relation']['parents']) > 1) {
56            foreach ($this['relation']['parents'] as $item) {
57                if ($item['path'] == $this['path']) {
58                    return $item['id'];
59                }
60            }
61        } elseif (count($this['relation']['parents']) == 1) {
62            return $this['relation']['parents'][0]['id'];
63        }
64        return $this['id'];
65    }
66}