• File: ShellProcessor.php
  • Full Path: /var/www/crm_set/modules/backup/vendor/backup-manager/backup-manager/src/ShellProcessing/ShellProcessor.php
  • Date Modified: 09/21/2026 4:20 AM
  • File size: 868 bytes
  • MIME-type: text/x-php
  • Charset: utf-8
<?php namespace BackupManager\ShellProcessing;

use Symfony\Component\Process\Process;

/**
 * Class CommandProcessor
 * @package BackupManager
 */
class ShellProcessor {

    /** @var Process */
    private $process;

    /**
     * @param Process $process
     */
    public function __construct(Process $process) {
        $this->process = $process;
    }

    /**
     * @param $command
     * @throws ShellProcessFailed
     * @throws \Symfony\Component\Process\Exception\LogicException
     */
    public function process($command) {
        if (empty($command)) {
            return;
        }

        $this->process->setCommandLine($command);
        $this->process->setTimeout(null);
        $this->process->run();
        if ( ! $this->process->isSuccessful()) {
            throw new ShellProcessFailed($this->process->getErrorOutput());
        }
    }
}