Static code analysis.
This commit is contained in:
@ -4,24 +4,37 @@ namespace App\Rclone;
|
||||
use Symfony\Component\Process\Process;
|
||||
use Symfony\Component\Process\Exception\ProcessFailedException;
|
||||
|
||||
use Exception;
|
||||
|
||||
class Rclone
|
||||
{
|
||||
protected string $rclone_path;
|
||||
protected string $rclonePath;
|
||||
/**
|
||||
* Global options
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
protected array $global_options = [];
|
||||
protected array $globalOptions = [];
|
||||
|
||||
function __construct(string $rclone_path = "rclone")
|
||||
protected string $version = "";
|
||||
|
||||
function __construct(string $rclonePath = "rclone")
|
||||
{
|
||||
$this->rclone_path = $rclone_path;
|
||||
$this->rclonePath = $rclonePath;
|
||||
try
|
||||
{
|
||||
$version = $this->exec('--version');
|
||||
$this->version = explode("\n", $version)[0];
|
||||
}
|
||||
catch(ProcessFailedException $e)
|
||||
{
|
||||
throw new Exception("Check installation of rclone");
|
||||
}
|
||||
}
|
||||
|
||||
function getVersion(): string
|
||||
{
|
||||
return $this->exec('--version');
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
function getSize(string $path): int
|
||||
@ -52,8 +65,8 @@ class Rclone
|
||||
{
|
||||
$process = new Process(
|
||||
array_merge(
|
||||
[$this->rclone_path],
|
||||
$this->global_options,
|
||||
[$this->rclonePath],
|
||||
$this->globalOptions,
|
||||
[$command],
|
||||
$options
|
||||
)
|
||||
|
Reference in New Issue
Block a user