@@ 17-38 (lines=22) @@ | ||
14 | public $member_id; |
|
15 | public $territory; // Territory parameters |
|
16 | ||
17 | public static function fromArray(array $params) |
|
18 | { |
|
19 | if (!isset($params['territory_name'])) { |
|
20 | throw new BadParam('Territory name must be provided'); |
|
21 | } |
|
22 | ||
23 | if (!isset($params['territory_color'])) { |
|
24 | throw new BadParam('Territory color must be provided'); |
|
25 | } |
|
26 | ||
27 | if (!isset($params['territory'])) { |
|
28 | throw new BadParam('Territory must be provided'); |
|
29 | } |
|
30 | ||
31 | $avoidanceZoneParameters = new AvoidanceZone(); |
|
32 | ||
33 | foreach($params as $key => $value) { |
|
34 | if (property_exists($avoidanceZoneParameters, $key)) { |
|
35 | $avoidanceZoneParameters->{$key} = $value; |
|
36 | } |
|
37 | } |
|
38 | ||
39 | return $avoidanceZoneParameters; |
|
40 | } |
|
41 |
@@ 17-38 (lines=22) @@ | ||
14 | public $member_id; |
|
15 | public $territory; // Territory parameters |
|
16 | ||
17 | public static function fromArray(array $params) { |
|
18 | if (!isset($params['territory_name'])) { |
|
19 | throw new BadParam('Territory name must be provided'); |
|
20 | } |
|
21 | ||
22 | if (!isset($params['territory_color'])) { |
|
23 | throw new BadParam('Territory color must be provided'); |
|
24 | } |
|
25 | ||
26 | if (!isset($params['territory'])) { |
|
27 | throw new BadParam('Territory must be provided'); |
|
28 | } |
|
29 | ||
30 | $territoryparameters = new Territory(); |
|
31 | ||
32 | foreach($params as $key => $value) { |
|
33 | if (property_exists($territoryparameters, $key)) { |
|
34 | $territoryparameters->{$key} = $value; |
|
35 | } |
|
36 | } |
|
37 | ||
38 | return $territoryparameters; |
|
39 | } |
|
40 | ||
41 | public static function getTerritory($params) |