<commit_before><?php

namespace Pingpong\Modules\Migrations;

class Migrator
{
    /**
     * Pingpong Module instance.
     *
     * @var \Pingpong\Modules\Module
     */
    protected $module;

    /**
     * Laravel Application instance.
     *
     * @var \Illuminate\Foundation\Application.
     */
    protected $laravel;

    /**
     * Create new instance.
     *
     * @param \Pingpong\Modules\Module $module
     */
    public function __construct($module)
    {
        $this->module = $module;
        $this->laravel = $module->getLaravel();
    }

    /**
     * Get migration path.
     *
     * @return string
     */
    public function getPath()
    {
        return $this->module->getExtraPath(
            config('modules.paths.generator.migration')
        );
    }

    /**
     * Get migration files.
     *
     * @return array
     */
    public function getMigrations()
    {
        $files = $this->laravel['files']->glob($this->getPath().'/*_*.php');

        // Once we have the array of files in the directory we will just remove the
        // extension and take the basename of the file which is all we need when
        // finding the migrations that haven't been run against the databases.
        if ($files === false) {
            return array();
        }

        $files = array_map(function ($file) {
            return str_replace('.php', '', basename($file));

        }, $files);

        // Once we have all of the formatted file names we will sort them and since
        // they all start with a timestamp this should give us the migrations in
        // the order they were actually created by the application developers.
        sort($files);

        return $files;
    }

    /**
     * Migrate migrations.
     *
     * @return array
     */
    public function migrate()
    {
        $migrations = array_reverse($this->getMigrations());

        $this->requireFiles($migrations);

        // Once we grab all of the migration files for the path, we will compare them
        // against the migrations that have already been run for this package then
        // run each of the outstanding migrations against a database connection.
        $migrations = array_diff($migrations, $this->getRan());

        $migrated = [];

        foreach ($migrations as $migration) {
            $migrated[] = $migration;

            $this->up($migration);

            $this->log($migration);
        }

        return $migrated;
    }

    /**
     * Rollback migration.
     *
     * @return array<commit_msg>Do not reverse migrations<commit_after><?php

namespace Pingpong\Modules\Migrations;

class Migrator
{
    /**
     * Pingpong Module instance.
     *
     * @var \Pingpong\Modules\Module
     */
    protected $module;

    /**
     * Laravel Application instance.
     *
     * @var \Illuminate\Foundation\Application.
     */
    protected $laravel;

    /**
     * Create new instance.
     *
     * @param \Pingpong\Modules\Module $module
     */
    public function __construct($module)
    {
        $this->module = $module;
        $this->laravel = $module->getLaravel();
    }

    /**
     * Get migration path.
     *
     * @return string
     */
    public function getPath()
    {
        return $this->module->getExtraPath(
            config('modules.paths.generator.migration')
        );
    }

    /**
     * Get migration files.
     *
     * @return array
     */
    public function getMigrations()
    {
        $files = $this->laravel['files']->glob($this->getPath().'/*_*.php');

        // Once we have the array of files in the directory we will just remove the
        // extension and take the basename of the file which is all we need when
        // finding the migrations that haven't been run against the databases.
        if ($files === false) {
            return array();
        }

        $files = array_map(function ($file) {
            return str_replace('.php', '', basename($file));

        }, $files);

        // Once we have all of the formatted file names we will sort them and since
        // they all start with a timestamp this should give us the migrations in
        // the order they were actually created by the application developers.
        sort($files);

        return $files;
    }

    /**
     * Migrate migrations.
     *
     * @return array
     */
    public function migrate()
    {
        $migrations = $this->getMigrations();

        $this->requireFiles($migrations);

        // Once we grab all of the migration files for the path, we will compare them
        // against the migrations that have already been run for this package then
        // run each of the outstanding migrations against a database connection.
        $migrations = array_diff($migrations, $this->getRan());

        $migrated = [];

        foreach ($migrations as $migration) {
            $migrated[] = $migration;

            $this->up($migration);

            $this->log($migration);
        }

        return $migrated;
    }

    /**
     * Rollback migration.
     *
     * @return array
{'fraction_non_alphanumeric': 0.11466719026114275, 'fraction_numerical': 0.0, 'mean_word_length': 1.891032917139614, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '6475262', 'n_tokens_mistral': 1403, 'n_tokens_neox': 1393, 'n_words': 422}