Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 22 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| SearchResults | |
0.00% |
0 / 22 |
|
0.00% |
0 / 4 |
156 | |
0.00% |
0 / 1 |
| getNames | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| toSearchResultData | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
20 | |||
| addSearchResultsData | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| sortByType | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
20 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @package Zmsdldb |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
| 6 | **/ |
| 7 | |
| 8 | namespace BO\Zmsdldb\Collection; |
| 9 | |
| 10 | use BO\Zmsdldb\Entity\SearchResult as Entity; |
| 11 | |
| 12 | class SearchResults extends Base |
| 13 | { |
| 14 | /** |
| 15 | * @psalm-api |
| 16 | */ |
| 17 | public function getNames(): array |
| 18 | { |
| 19 | $nameList = array(); |
| 20 | foreach ($this as $item) { |
| 21 | $nameList[$item->getId()] = $item->getName(); |
| 22 | } |
| 23 | return $nameList; |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * @psalm-api |
| 28 | */ |
| 29 | public function toSearchResultData(): self |
| 30 | { |
| 31 | $list = new self(); |
| 32 | foreach ($this as $results) { |
| 33 | foreach ($results as $data) { |
| 34 | if (count($data)) { |
| 35 | $item = Entity::create($data); |
| 36 | $list[] = $item; |
| 37 | } |
| 38 | } |
| 39 | $list; |
| 40 | } |
| 41 | return $list; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * @psalm-api |
| 46 | * |
| 47 | * @return null|static |
| 48 | */ |
| 49 | public function addSearchResultsData($data): static|null |
| 50 | { |
| 51 | if ($data) { |
| 52 | $this[] = $data; |
| 53 | return $this; |
| 54 | } |
| 55 | return null; |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * @psalm-api |
| 60 | */ |
| 61 | public function sortByType(array $order): self |
| 62 | { |
| 63 | $list = new self(); |
| 64 | foreach ($order as $type) { |
| 65 | foreach ($this as $item) { |
| 66 | if ($item->getType() == $type) { |
| 67 | $list[] = $item; |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | return $list; |
| 72 | } |
| 73 | } |