msd Backup hinzugefügt
This commit is contained in:
59
msd/vendor/league/flysystem-sftp/StubSftpConnectionProvider.php
vendored
Normal file
59
msd/vendor/league/flysystem-sftp/StubSftpConnectionProvider.php
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace League\Flysystem\PhpseclibV2;
|
||||
|
||||
use phpseclib\Net\SFTP;
|
||||
|
||||
class StubSftpConnectionProvider implements ConnectionProvider
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $host;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $username;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $password;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $port;
|
||||
|
||||
/**
|
||||
* @var SftpStub
|
||||
*/
|
||||
private $connection;
|
||||
|
||||
public function __construct(
|
||||
string $host,
|
||||
string $username,
|
||||
string $password = null,
|
||||
int $port = 22
|
||||
) {
|
||||
$this->host = $host;
|
||||
$this->username = $username;
|
||||
$this->password = $password;
|
||||
$this->port = $port;
|
||||
}
|
||||
|
||||
public function provideConnection(): SFTP
|
||||
{
|
||||
if ( ! $this->connection instanceof SFTP) {
|
||||
$connection = new SftpStub($this->host, $this->port);
|
||||
$connection->login($this->username, $this->password);
|
||||
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
return $this->connection;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user