/** * Hydrate the supplied array of parameters into an instance of Forecast * * @param array $value * * @return Forecast|null */ public function hydrate($value) { if (!is_array($value)) { return null; } if (isset($value['time']) && is_array($value['time'])) { $times = array(); $timeStrategy = new TimeStrategy(); foreach ($value['time'] as $data) { if (is_array($data)) { $times[] = $timeStrategy->hydrate($data, new Time()); } continue; } $value['times'] = $times; unset($value['time']); } return $this->getHydrator()->hydrate($value, new Forecast()); }
/** * @covers \OpenWeatherMap\Hydrator\Strategy\TimeStrategy::extract */ public function testExtractReturnsNull() { $timeStrategy = new TimeStrategy(); $this->assertNull($timeStrategy->extract(new stdClass())); }