Static code analysis.

This commit is contained in:
2023-05-31 09:00:20 +00:00
parent 4c8f71d9d8
commit 19f27e6d0c
10 changed files with 1798 additions and 43 deletions

View File

@ -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
)