public function testWithData1() { $data = file_get_contents('tests/support/vtmis-1.htm'); $e = new VTMISExtractor(); $e->input($data); $expectedOutput = ['Калиакра' => ['wind_speed' => '6.3', 'wind_gust_speed' => '6.3', 'wind_direction' => '271', 'temperature' => '14.9', 'pressure' => '982.6'], 'Балчик' => ['wind_speed' => '3.5', 'wind_gust_speed' => '3.9', 'wind_direction' => '221', 'temperature' => '15', 'pressure' => '1000.6']]; $this->assertArraySubset($expectedOutput, $e->output()); }
/** * Execute the console command. * * @return mixed */ public function handle() { $data = file_get_contents(self::$URL); $e = new VTMISExtractor(); $e->input($data); foreach ($e->output() as $name => $data) { $spot = $this->spots->getOrCreateByName($name); $measurement = new Measurement(); $measurement->spot_id = $spot->id; foreach ($data as $key => $value) { $measurement->{$key} = $value; } $measurement->save(); } }