HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/posscale/www/printmanager/vendor/league/flysystem-sftp-v3/SimpleConnectivityChecker.php
<?php

declare(strict_types=1);

namespace League\Flysystem\PhpseclibV3;

use phpseclib3\Net\SFTP;
use Throwable;

class SimpleConnectivityChecker implements ConnectivityChecker
{
    public function __construct(
        private bool $usePing = false,
    ) {
    }

    public static function create(): SimpleConnectivityChecker
    {
        return new SimpleConnectivityChecker();
    }

    public function withUsingPing(bool $usePing): SimpleConnectivityChecker
    {
        $clone = clone $this;
        $clone->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;
        }
    }
}