Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
93.10% |
27 / 29 |
|
80.00% |
8 / 10 |
CRAP | |
0.00% |
0 / 1 |
Authority | |
93.10% |
27 / 29 |
|
80.00% |
8 / 10 |
19.12 | |
0.00% |
0 / 1 |
__clone | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 | |||
create | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
hasAppointments | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |||
hasLocations | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
getLocationListByOfficePath | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 | |||
hasLocationId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
removeLocation | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
isInServiceList | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
5 | |||
clearLocations | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
addLocation | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
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 service export |
12 | */ |
13 | class Authority extends Base |
14 | { |
15 | public function __clone() |
16 | { |
17 | if ($this['locations'] instanceof \BO\Zmsdldb\Collection\Locations) { |
18 | $this['locations'] = clone $this['locations']; |
19 | } |
20 | } |
21 | |
22 | public static function create($name) |
23 | { |
24 | $data = array( |
25 | 'name' => $name, |
26 | 'locations' => new \BO\Zmsdldb\Collection\Locations() |
27 | ); |
28 | return new self($data); |
29 | } |
30 | |
31 | /** |
32 | * Check if appointments are available |
33 | * |
34 | * @param String $serviceCsv |
35 | * only check for this serviceCsv |
36 | * @param Bool $external |
37 | * allow external links, default false |
38 | * |
39 | * @return Bool |
40 | */ |
41 | public function hasAppointments($serviceCsv = null, $external = false) |
42 | { |
43 | foreach ($this['locations'] as $location) { |
44 | if ($location->hasAppointments($serviceCsv, $external)) { |
45 | return true; |
46 | } |
47 | } |
48 | return false; |
49 | } |
50 | |
51 | /** |
52 | * Check if locations are available |
53 | * |
54 | * @return Bool |
55 | */ |
56 | public function hasLocations() |
57 | { |
58 | return count($this['locations']) > 0 ? true : false; |
59 | } |
60 | |
61 | /** |
62 | * |
63 | * @param String $officepath |
64 | * only check for this office |
65 | * @return Authority |
66 | * |
67 | */ |
68 | public function getLocationListByOfficePath($officepath) |
69 | { |
70 | $authority = clone $this; |
71 | if (count($authority['locations'])) { |
72 | $locations = new \BO\Zmsdldb\Collection\Locations($authority['locations']); |
73 | $authority['locations'] = $locations->getLocationListByOfficePath($officepath); |
74 | } |
75 | return $authority; |
76 | } |
77 | |
78 | /** |
79 | * |
80 | * @param Int $locationId |
81 | * |
82 | * @return Bool |
83 | */ |
84 | public function hasLocationId($locationId) |
85 | { |
86 | return $this['locations']->hasLocationId($locationId); |
87 | } |
88 | |
89 | /** |
90 | * Remove a location |
91 | * |
92 | * @param Int $locationId |
93 | * |
94 | * @return clone self |
95 | */ |
96 | public function removeLocation($locationId) |
97 | { |
98 | $authority = clone $this; |
99 | $authority['locations'] = $authority['locations']->removeLocation($locationId); |
100 | return $authority; |
101 | } |
102 | |
103 | /** |
104 | * Check if Authority is part of ServiceList |
105 | * |
106 | * @param String $serviceCsv |
107 | * only check for this serviceCsv |
108 | * |
109 | * @return clone self |
110 | */ |
111 | public function isInServiceList($servicelist = array()) |
112 | { |
113 | foreach ($servicelist as $service) { |
114 | if ($service->offsetExists('authorities')) { |
115 | foreach ($service['authorities'] as $authority) { |
116 | if ($authority['id'] == $this['id']) { |
117 | return true; |
118 | } |
119 | } |
120 | } |
121 | } |
122 | return false; |
123 | } |
124 | |
125 | public function clearLocations() |
126 | { |
127 | $this['locations'] = new \BO\Zmsdldb\Collection\Locations(); |
128 | } |
129 | |
130 | public function addLocation(\BO\Zmsdldb\Entity\Location $location) |
131 | { |
132 | $this['locations'][$location['id']] = $location; |
133 | } |
134 | } |