usePing = $usePing; return $clone; } public function isConnected(SFTP $connection): bool { if ( ! $connection->isConnected()) { return false; } if ( ! $this->usePing) { return true; } try { return $connection->ping(); } catch (Throwable) { return false; } } }