refactoring

This commit is contained in:
Saeed Vaziry
2023-08-04 18:28:04 +02:00
parent 8444323cf4
commit 643318fcfc
349 changed files with 3189 additions and 2729 deletions

View File

@ -4,41 +4,23 @@
use App\SSHCommands\Command;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class DeleteUserCommand extends Command
{
/**
* @var string
*/
protected $provider;
/**
* @var string
*/
protected $username;
/**
* @var string
*/
protected $host;
public function __construct($provider, $username, $host)
public function __construct(protected string $provider, protected string $username, protected string $host)
{
$this->provider = $provider;
$this->username = $username;
$this->host = $host;
}
public function file(string $os): string
public function file(): string
{
return File::get(base_path('system/commands/database/'.$this->provider.'/delete-user.sh'));
return File::get(resource_path(sprintf("commands/database/%s/delete-user.sh", $this->provider)));
}
public function content(string $os): string
public function content(): string
{
$command = Str::replace('__username__', $this->username, $this->file($os));
return Str::replace('__host__', $this->host, $command);
return str($this->file())
->replace('__username__', $this->username)
->replace('__host__', $this->host)
->toString();
}
}