Lines
52.27%
23 / 44
Methods
72.72%
8 / 11
Classes
0.00%
0 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| [BO\Zmsdldb\Collection\Locations] __clone | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 2 | ||
| [BO\Zmsdldb\Collection\Locations] hasLocationId | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [BO\Zmsdldb\Collection\Locations] removeLocation | 100.00% | 4 / 4 | 100.00% | 1 / 1 | 2 | ||
| [BO\Zmsdldb\Collection\Locations] getLocationsWithAppointmentsFor | 100.00% | 5 / 5 | 100.00% | 1 / 1 | 3 | ||
| [BO\Zmsdldb\Collection\Locations] getIds | 100.00% | 4 / 4 | 100.00% | 1 / 1 | 2 | ||
| [BO\Zmsdldb\Collection\Locations] getNames | 0.00% | 0 / 4 | 0.00% | 0 / 1 | 6 | ||
| [BO\Zmsdldb\Collection\Locations] getCSV | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [BO\Zmsdldb\Collection\Locations] getLocationListByOfficePath | 100.00% | 5 / 5 | 100.00% | 1 / 1 | 3 | ||
| [BO\Zmsdldb\Collection\Base] offsetSet | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [BO\Zmsdldb\Collection\Base] sortByName | 0.00% | 0 / 5 | 0.00% | 0 / 1 | 2 | ||
| [BO\Zmsdldb\Collection\Base] sortWithCollator | 0.00% | 0 / 12 | 0.00% | 0 / 1 | 6 | ||
| 15 | class Locations extends Base | |
| 16 | { | |
| 17 | } |
Inherited from BO\Zmsdldb\Collection\Locations
| 15 | public function __clone() | |
| 16 | { | |
| 17 | foreach ($this as $key => $location) { | |
| 18 | $this[$key] = clone $location; | |
| 19 | } | |
| 20 | } |
| 27 | public function hasLocationId($locationId): bool | |
| 28 | { | |
| 29 | return $this->offsetExists($locationId); | |
| 30 | } |
| 40 | public function removeLocation($locationId) | |
| 41 | { | |
| 42 | $locationList = clone $this; | |
| 43 | if ($locationList->hasLocationId($locationId)) { | |
| 44 | unset($locationList[$locationId]); | |
| 45 | } | |
| 46 | return $locationList; | |
| 47 | } |
| 55 | public function getLocationsWithAppointmentsFor($serviceCsv = null, $external = false): self | |
| 56 | { | |
| 57 | $list = new self(); | |
| 58 | foreach ($this as $location) { | |
| 59 | if ($location->hasAppointments($serviceCsv, $external)) { | |
| 60 | $list->append($location); | |
| 61 | } | |
| 62 | } | |
| 63 | return $list; | |
| 64 | } |
| 66 | public function getIds(): array | |
| 67 | { | |
| 68 | $idList = array(); | |
| 69 | foreach ($this as $location) { | |
| 70 | $idList[] = $location['id']; | |
| 71 | } | |
| 72 | return $idList; | |
| 73 | } |
| 78 | public function getNames(): array | |
| 79 | { | |
| 80 | $nameList = array(); | |
| 81 | foreach ($this as $location) { | |
| 82 | $nameList[$location['id']] = $location['name']; | |
| 83 | } | |
| 84 | return $nameList; | |
| 85 | } |
| 87 | public function getCSV(): string | |
| 88 | { | |
| 89 | return implode(',', $this->getIds()); | |
| 90 | } |
| 92 | public function getLocationListByOfficePath(string $officepath): self | |
| 93 | { | |
| 94 | $locationList = new self(); | |
| 95 | foreach ($this as $location_id => $location) { | |
| 96 | if ($location['office'] == $officepath) { | |
| 97 | $locationList[$location_id] = $location; | |
| 98 | } | |
| 99 | } | |
| 100 | return $locationList; | |
| 101 | } |
Inherited from BO\Zmsdldb\Collection\Base
| 19 | public function offsetSet(mixed $key, mixed $value): void | |
| 20 | { | |
| 21 | parent::offsetSet($key, $value); | |
| 22 | } |
| 24 | public function sortByName(): static | |
| 25 | { | |
| 26 | $itemList = clone $this; | |
| 27 | $itemList->uasort(function ($a, $b) { | |
| 28 | return strcmp(Sorter::toSortableString($a->getName()), Sorter::toSortableString($b->getName())); | |
| 29 | }); | |
| 30 | return $itemList; | |
| 31 | } |
| 36 | public function sortWithCollator(string $field = 'name', string $locale = 'de'): static | |
| 37 | { | |
| 38 | $collator = collator_create($locale); | |
| 39 | if ($collator === null) { | |
| 40 | throw new \RuntimeException('Could not create collator for locale ' . $locale); | |
| 41 | } | |
| 42 | $collator->setStrength(\Collator::QUATERNARY); | |
| 43 | $collator->setAttribute(\Collator::QUATERNARY, \Collator::ON); | |
| 44 | $collator->setAttribute(\Collator::CASE_FIRST, \Collator::ON); | |
| 45 | $collator->setAttribute(\Collator::NUMERIC_COLLATION, \Collator::ON); | |
| 46 | ||
| 47 | $itemList = clone $this; | |
| 48 | $itemList->uasort(function ($itemA, $itemB) use ($collator, $field) { | |
| 49 | return collator_compare($collator, $itemA[$field], $itemB[$field]); | |
| 50 | }); | |
| 51 | return $itemList; | |
| 52 | } |