<commit_before><?php
namespace phpbu\Backup\Source;

use phpbu\App\Result;
use phpbu\Backup\Cli;
use phpbu\Backup\Source;
use phpbu\Backup\Target;
use phpbu\Util;

class Tar implements Source
{
    /**
     * Executor to run the tar shell command.
     *
     * @var phpbu\Cli\Exec
     */
    private $exec;

    /**
     * Configuration
     *
     * @var array
     */
    private $conf;

    /**
     * Setup.
     *
     * @see    phpbu\Backup\Source
     * @param  array               $conf
     * @throws RuntimeException
     */
    public function setup(array $conf = array())
    {
        $this->conf = $conf;
    }

    /**
     *
     * @param  phpbu\Backup\Target $target
     * @param  phpbu\App\Result    $result
     * @return phpbu\App\Result
     */
    public function backup(Target $target, Result $result)
    {
        $this->exec = new Cli\Exec();
        $this->exec->setTarget($target);
        $this->exec->setOutputCompression(false);

        $compressOption     = '';
        $allowedCompressors = array(
            'bzip2' => 'j',
            'gzip'  => 'z',
        );

        // check if 'tar' can handle the requested compression
        if ($target->shouldBeCompressed()) {
            $compressor = $target->getCompressor();
            $name       = $compressor->getCommand(false);
            if (isset($allowedCompressors[$name])) {
                $compressOption = $allowedCompressors[$name];
            } else {
                // the requested compression is not available for the 'tar' command
                $target->disableCompression();
            }
        }

        $path = isset($this->conf['pathToTar']) ? $this->conf['pathToTar'] : null;
        $tar  = Util\Cli::detectCmdLocation('tar', $path);
        $cmd  = new Cli\Cmd($tar);
        $cmd->addOption(
            '-' . $compressOption . 'cvf',
            array(
                (string) $target,
                $this->conf['dir'],
            )
        );
        $this->exec->addCommand($cmd);

        $r = $this->exec->execute();

        echo $r->getCmd() . PHP_EOL;

        return $result;
    }
}<commit_msg>Removed 'tar' verbose option<commit_after><?php
namespace phpbu\Backup\Source;

use phpbu\App\Result;
use phpbu\Backup\Cli;
use phpbu\Backup\Source;
use phpbu\Backup\Target;
use phpbu\Util;

class Tar implements Source
{
    /**
     * Executor to run the tar shell command.
     *
     * @var phpbu\Cli\Exec
     */
    private $exec;

    /**
     * Configuration
     *
     * @var array
     */
    private $conf;

    /**
     * Setup.
     *
     * @see    phpbu\Backup\Source
     * @param  array               $conf
     * @throws RuntimeException
     */
    public function setup(array $conf = array())
    {
        $this->conf = $conf;
    }

    /**
     *
     * @param  phpbu\Backup\Target $target
     * @param  phpbu\App\Result    $result
     * @return phpbu\App\Result
     */
    public function backup(Target $target, Result $result)
    {
        $this->exec = new Cli\Exec();
        $this->exec->setTarget($target);
        $this->exec->setOutputCompression(false);

        $compressOption     = '';
        $allowedCompressors = array(
            'bzip2' => 'j',
            'gzip'  => 'z',
        );

        // check if 'tar' can handle the requested compression
        if ($target->shouldBeCompressed()) {
            $compressor = $target->getCompressor();
            $name       = $compressor->getCommand(false);
            if (isset($allowedCompressors[$name])) {
                $compressOption = $allowedCompressors[$name];
            } else {
                // the requested compression is not available for the 'tar' command
                $target->disableCompression();
            }
        }

        $path = isset($this->conf['pathToTar']) ? $this->conf['pathToTar'] : null;
        $tar  = Util\Cli::detectCmdLocation('tar', $path);
        $cmd  = new Cli\Cmd($tar);
        $cmd->addOption(
            '-' . $compressOption . 'cf',
            array(
                (string) $target,
                $this->conf['dir'],
            )
        );
        $this->exec->addCommand($cmd);

        $r = $this->exec->execute();

        echo $r->getCmd() . PHP_EOL;

        return $result;
    }
}
{'fraction_non_alphanumeric': 0.14593077642656688, 'fraction_numerical': 0.0004677268475210477, 'mean_word_length': 1.6933249370277077, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3722738', 'n_tokens_mistral': 1323, 'n_tokens_neox': 1274, 'n_words': 261}