$ping, 'download' => $down['val'], 'upload' => $up['val'] ]); return $test; } public static function latest() { $data = Speedtest::latest()->get(); if($data->isEmpty()) { return false; } return $data->first(); } public static function parseUnits($input) { $input = explode(' ', $input); $val = $input[0]; $unit = explode('/', $input[1])[0]; switch($unit) { case 'Mbyte': $val = $val * 8; break; case 'Kbit': $val = $val / 1000; break; case 'Kbyte': $val = $val / 125; break; case 'Mbit': default: break; } return [ 'val' => $val, 'unit' => 'Mbit/s' ]; } }