Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
84.62% |
22 / 26 |
|
87.50% |
7 / 8 |
CRAP | |
0.00% |
0 / 1 |
| Locations | |
84.62% |
22 / 26 |
|
87.50% |
7 / 8 |
16.93 | |
0.00% |
0 / 1 |
| __clone | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 | |||
| hasLocationId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| removeLocation | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
| getLocationsWithAppointmentsFor | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
3 | |||
| getIds | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
| getNames | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| getCSV | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getLocationListByOfficePath | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @package Zmsdldb |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
| 6 | **/ |
| 7 | |
| 8 | namespace BO\Zmsdldb\Collection; |
| 9 | |
| 10 | class Locations extends Base |
| 11 | { |
| 12 | public function __clone() |
| 13 | { |
| 14 | foreach ($this as $key => $location) { |
| 15 | $this[$key] = clone $location; |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * @param int $locationId |
| 21 | * |
| 22 | * @return Bool |
| 23 | */ |
| 24 | public function hasLocationId($locationId): bool |
| 25 | { |
| 26 | return $this->offsetExists($locationId); |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Remove a location |
| 31 | * |
| 32 | * @param Int $locationId |
| 33 | * |
| 34 | * @return clone self |
| 35 | */ |
| 36 | public function removeLocation($locationId) |
| 37 | { |
| 38 | $locationList = clone $this; |
| 39 | if ($locationList->hasLocationId($locationId)) { |
| 40 | unset($locationList[$locationId]); |
| 41 | } |
| 42 | return $locationList; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * find locations with appointments |
| 47 | * |
| 48 | * @param String $serviceCsv only check for this serviceCsv |
| 49 | * @param Bool $external allow external links, default false |
| 50 | */ |
| 51 | public function getLocationsWithAppointmentsFor($serviceCsv = null, $external = false) |
| 52 | { |
| 53 | $list = new self(); |
| 54 | foreach ($this as $location) { |
| 55 | if ($location->hasAppointments($serviceCsv, $external)) { |
| 56 | $list[] = $location; |
| 57 | } |
| 58 | } |
| 59 | return $list; |
| 60 | } |
| 61 | |
| 62 | public function getIds() |
| 63 | { |
| 64 | $idList = array(); |
| 65 | foreach ($this as $location) { |
| 66 | $idList[] = $location['id']; |
| 67 | } |
| 68 | return $idList; |
| 69 | } |
| 70 | |
| 71 | public function getNames() |
| 72 | { |
| 73 | $nameList = array(); |
| 74 | foreach ($this as $location) { |
| 75 | $nameList[$location['id']] = $location['name']; |
| 76 | } |
| 77 | return $nameList; |
| 78 | } |
| 79 | |
| 80 | public function getCSV() |
| 81 | { |
| 82 | return implode(',', $this->getIds()); |
| 83 | } |
| 84 | |
| 85 | public function getLocationListByOfficePath($officepath) |
| 86 | { |
| 87 | $locationList = new self(); |
| 88 | foreach ($this as $location_id => $location) { |
| 89 | if ($location['office'] == $officepath) { |
| 90 | $locationList[$location_id] = $location; |
| 91 | } |
| 92 | } |
| 93 | return $locationList; |
| 94 | } |
| 95 | } |