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