Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 5
Shell
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 3
12
0.00% covered (danger)
0.00%
0 / 5
 __construct
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 get
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 run
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
<?php
namespace Eywa\Console;
use Traversable;
use Symfony\Component\Process\Process;
class Shell
{
    /**
     * @var array<string>
     */
    private array $commands;
    /**
     * @var Process<mixed>
     */
    private Process $process;
    /**
     * Shell constructor.
     * @param string $command
     */
    public function __construct(string $command)
    {
        $this->process = Process::fromShellCommandline($command);
    }
    /**
     * @return Process
     */
    public function get(): Process
    {
        return $this->process;
    }
    /**
     *
     * Run the thell command
     *
     * @param callable|null $callback
     * @param array<mixed> $env
     *
     * @return bool
     *
     */
    public function run(callable $callback = null, array $env = []): bool
    {
        $this->process->run($callback, $env);
        return $this->process->isSuccessful();
    }
}