public function getCommand($command = null, $arguments = [], $flags = [], $environmentVariables = [])
    {
        // Format arguments
        $arguments = $this->buildArguments($arguments);
        $options = $this->buildOptions($flags);
        $environmentVariables = $this->buildEnvironmentVariables($environmentVariables);

        // Build command
        $binary = $this->getBinary();
        $components = [$command, $arguments, $options];
        foreach ($components as $component) {
            if ($component) {
                $binary .= ' '.$component;
            }
        }

        // If the binary has a parent, wrap the call with it
        $parent = $this->parent instanceof self ? $this->parent->getBinary() : $this->parent;
        $command = $environmentVariables.$parent.' '.$binary;

        return trim($command);
    }