<commit_before><?php
namespace phpbu\Laravel\Configuration;

use phpbu\App\Configuration;
use phpbu\App\Configuration\Backup\Target;

/**
 * Class Translator
 *
 * @package    phpbu\Laravel
 * @author     <NAME> <<EMAIL>>
 * @copyright  <NAME> <<EMAIL>>
 * @license    http://www.opensource.org/licenses/MIT The MIT License (MIT)
 * @link       http://phpbu.de/
 */
class Translator
{
    /**
     * Configuration Proxy
     *
     * @var \phpbu\Laravel\Configuration\Proxy
     */
    private $proxy;

    /**
     * Configurable laravel backup types.
     *
     * @var array
     */
    private $types = [
        'directories' => 'directoryConfigToBackup',
        'databases'   => 'databaseConfigToBackup',
    ];

    /**
     * Translates the laravel configuration to a phpbu configuration.
     *
     * @param  \phpbu\Laravel\Configuration\Proxy $proxy
     * @return \phpbu\App\Configuration
     * @throws \phpbu\Laravel\Configuration\Exception
     */
    public function translate(Proxy $proxy)
    {
        $this->proxy   = $proxy;
        $laravelPhpbu  = $this->proxy->get('phpbu');
        $configuration = new Configuration(realpath(dirname($laravelPhpbu['config']) . '/..'));
        $configuration->setFilename($laravelPhpbu['config']);

        // walk the the configured backups
        foreach ($this->types as $type => $translationMethod) {
            // create a phpbu backup config
            foreach ($laravelPhpbu[$type] as $conf) {
                $backup = $this->{$translationMethod}($conf);
                $backup->setTarget($this->translateTarget($conf['target']));

                $this->addChecksIfConfigured($backup, $conf);
                $this->addSyncIfConfigured($backup, $conf);
                $this->addCleanupIfConfigured($backup, $conf);

                $configuration->addBackup($backup);
            }
        }

        return $configuration;
    }

    /**<commit_msg>Removed cwd guessing, fixed in phpbu 2.1.5<commit_after><?php
namespace phpbu\Laravel\Configuration;

use phpbu\App\Configuration;
use phpbu\App\Configuration\Backup\Target;

/**
 * Class Translator
 *
 * @package    phpbu\Laravel
 * @author     <NAME> <<EMAIL>>
 * @copyright  <NAME> <<EMAIL>>
 * @license    http://www.opensource.org/licenses/MIT The MIT License (MIT)
 * @link       http://phpbu.de/
 */
class Translator
{
    /**
     * Configuration Proxy
     *
     * @var \phpbu\Laravel\Configuration\Proxy
     */
    private $proxy;

    /**
     * Configurable laravel backup types.
     *
     * @var array
     */
    private $types = [
        'directories' => 'directoryConfigToBackup',
        'databases'   => 'databaseConfigToBackup',
    ];

    /**
     * Translates the laravel configuration to a phpbu configuration.
     *
     * @param  \phpbu\Laravel\Configuration\Proxy $proxy
     * @return \phpbu\App\Configuration
     * @throws \phpbu\Laravel\Configuration\Exception
     */
    public function translate(Proxy $proxy)
    {
        $this->proxy   = $proxy;
        $laravelPhpbu  = $this->proxy->get('phpbu');
        $configuration = new Configuration();
        $configuration->setFilename($laravelPhpbu['config']);

        // walk the the configured backups
        foreach ($this->types as $type => $translationMethod) {
            // create a phpbu backup config
            foreach ($laravelPhpbu[$type] as $conf) {
                $backup = $this->{$translationMethod}($conf);
                $backup->setTarget($this->translateTarget($conf['target']));

                $this->addChecksIfConfigured($backup, $conf);
                $this->addSyncIfConfigured($backup, $conf);
                $this->addCleanupIfConfigured($backup, $conf);

                $configuration->addBackup($backup);
            }
        }

        return $configuration;
    }

    /**
{'fraction_non_alphanumeric': 0.14110269140318787, 'fraction_numerical': 0.0007839038411288215, 'mean_word_length': 2.3085566119273984, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2865153', 'n_tokens_mistral': 1145, 'n_tokens_neox': 1093, 'n_words': 212}