Lines
0.00%
0 / 22
Functions and Methods
0.00%
0 / 4
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 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 | /** | |
| 13 | * @extends Base<\BO\Zmsdldb\Entity\SearchResult> | |
| 14 | */ | |
| 15 | class SearchResults extends Base | |
| 16 | { | |
| 17 | /** | |
| 18 | * @psalm-api | |
| 19 | */ | |
| 20 | public function getNames(): array | |
| 21 | { | |
| 22 | $nameList = array(); | |
| 23 | foreach ($this as $item) { | |
| 24 | $nameList[$item->getId()] = $item->getName(); | |
| 25 | } | |
| 26 | return $nameList; | |
| 27 | } | |
| 28 | ||
| 29 | /** | |
| 30 | * @psalm-api | |
| 31 | */ | |
| 32 | public function toSearchResultData(): self | |
| 33 | { | |
| 34 | $list = new self(); | |
| 35 | foreach ($this as $results) { | |
| 36 | foreach ($results as $data) { | |
| 37 | if (count($data)) { | |
| 38 | $item = Entity::create($data); | |
| 39 | $list->append($item); | |
| 40 | } | |
| 41 | } | |
| 42 | $list; | |
| 43 | } | |
| 44 | return $list; | |
| 45 | } | |
| 46 | ||
| 47 | /** | |
| 48 | * @psalm-api | |
| 49 | * | |
| 50 | * @return null|static | |
| 51 | */ | |
| 52 | public function addSearchResultsData(mixed $data): static|null | |
| 53 | { | |
| 54 | if ($data) { | |
| 55 | $this->append($data); | |
| 56 | return $this; | |
| 57 | } | |
| 58 | return null; | |
| 59 | } | |
| 60 | ||
| 61 | /** | |
| 62 | * @psalm-api | |
| 63 | */ | |
| 64 | public function sortByType(array $order): self | |
| 65 | { | |
| 66 | $list = new self(); | |
| 67 | foreach ($order as $type) { | |
| 68 | foreach ($this as $item) { | |
| 69 | if ($item->getType() == $type) { | |
| 70 | $list->append($item); | |
| 71 | } | |
| 72 | } | |
| 73 | } | |
| 74 | return $list; | |
| 75 | } | |
| 76 | } |