Skip to content

Commit 26612ab

Browse files
committed
Minor cleanup of Hydrator, still want a better solution.
1 parent 98d472e commit 26612ab

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/Hydrator.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,15 @@ public static function Coordinate(array $data)
157157
*/
158158
public static function CoordinateDatacenterMap(array $data)
159159
{
160-
$dcm = new CoordinateDatacenterMap();
161-
if (isset($data['Datacenter']))
162-
$dcm->Datacenter = $data['Datacenter'];
163160
if (isset($data['Coordinates']))
164161
{
165-
foreach($data['Coordinates'] as $coordinate)
162+
for ($i = 0, $cnt = count($data['Coordinates']); $i < $cnt; $i++)
166163
{
167-
$dcm->Coordinates[] = self::Coordinate($coordinate);
164+
$data['Coordinates'][$i] = self::Coordinate($data['Coordinates'][$i]);
168165
}
169166
}
170-
return $dcm;
167+
168+
return new CoordinateDatacenterMap($data);
171169
}
172170

173171
/**
@@ -209,20 +207,18 @@ public static function HealthCheck(array $data)
209207
*/
210208
public static function ServiceEntry(array $data)
211209
{
212-
$se = new ServiceEntry();
213-
$se->Node = $data['Node'];
214210
if (isset($data['Service']))
215-
$se->Service = self::AgentService($data['Service']);
216-
211+
$data['Service'] = self::AgentService($data['Service']);
212+
217213
if (isset($data['Checks']))
218214
{
219-
foreach($data['Checks'] as $check)
215+
for ($i = 0, $cnt = count($data['Checks']); $i < $cnt; $i++)
220216
{
221-
$se->Checks[] = self::HealthCheck($check);
217+
$data['Checks'][$i] = self::HealthCheck($data['Checks'][$i]);
222218
}
223219
}
224-
225-
return $se;
220+
221+
return new ServiceEntry($data);
226222
}
227223

228224
/**

0 commit comments

Comments
 (0)