angelcamposm / ping

A Ping package for Laravel
MIT License
55 stars 10 forks source link

Undefined array key 1 at PingParserForWindows.php #29

Open DaGLiMiOuX opened 1 year ago

DaGLiMiOuX commented 1 year ago

Hi there.

I've been trying to use your package for Laravel in order to use it to check status in some devices that will be configured within our application.

I've found that it works perfectly for Windows when the host exists, but it throws an error when the host does not exist. The system will be installed in a Linux, but our development team works with Windows 10. Can you please give it a check?

Undefined array key 1

at ...\vendor\acamposm\ping\src\Parsers\PingParserForWindows.php:130
    126▕     private function parseRoundTripTime(string $row): array
    127▕     {
    128▕         $rtt = explode(',', str_replace('ms', '', $row));
    129▕
  ➜ 130▕         $min = (float) explode(' = ', $rtt[0])[1] / 1000;
    131▕         $max = (float) explode(' = ', $rtt[1])[1] / 1000;
    132▕         $avg = (float) explode(' = ', $rtt[2])[1] / 1000;
    133▕
    134▕         return [

1   ...\vendor\acamposm\ping\src\Parsers\PingParserForWindows.php:130
      Illuminate\Foundation\Bootstrap\HandleExceptions::Illuminate\Foundation\Bootstrap\{closure}("Undefined array key 1", "...\vendor\acamposm\ping\src\Parsers\PingParserForWindows.php")

2   ...\vendor\acamposm\ping\src\Parsers\PingParserForWindows.php:181
      Acamposm\Ping\Parsers\PingParserForWindows::parseRoundTripTime("    (0% perdidos),")

Best regards, D.

faisalkhokher commented 1 year ago

Bugy code and package

Quadrubo commented 1 year ago

I also have this bug on Linux, how about you open a pull request to fix it?