<commit_before><?php

namespace Groovey\Migration;

use Symfony\Component\Finder\Finder;

class Migration
{
    private $app;

    public function __construct($app)
    {
        $this->app = $app;
    }

    public static function getTemplate()
    {
        $now = new \DateTime();
        $date = $now->format('Y-m-d H:i:s');

        $yaml = <<<YML
# Author: Name <<EMAIL>>
# Date: $date

# Run the migration
UP: >


# Reverse the migration
DOWN: >


YML;

        return $yaml;
    }

    public static function getDirectory()
    {
        return getcwd().'/database/migrations';
    }

    public static function getGeneratedVersion()
    {
        $finder = new Finder();
        $finder->files()->in(self::getDirectory());

        $versions = ['000'];

        foreach ($finder as $file) {
            $filename = $file->getRelativePathname();

            list($version, $description) = explode('_', $filename);
            $versions[] =  $version;
        }

        $last = end($versions);
        $new  = (int) $last + 1;

        return str_pad($new, 3, '0', STR_PAD_LEFT);
    }

    public static function getGeneratedFilename($argument)
    {
        $version = self::getGeneratedVersion();

        return $version.'_'.strtolower($argument).'.yml';
    }

    public function getAllFiles()
    {
        $finder = new Finder();

        return $finder->files()->in(self::getDirectory());
    }

    public static function getFileInfo($file)
    {
        list($version) = explode('_', $file);

        $description = str_replace('_', ' ', substr($file, 4, -4));

        return [
            'version'     => $version,
            'description' => $description,<commit_msg>Fix non static function getAllFiles<commit_after><?php

namespace Groovey\Migration;

use Symfony\Component\Finder\Finder;

class Migration
{
    private $app;

    public function __construct($app)
    {
        $this->app = $app;
    }

    public static function getTemplate()
    {
        $now = new \DateTime();
        $date = $now->format('Y-m-d H:i:s');

        $yaml = <<<YML
# Author: Name <<EMAIL>>
# Date: $date

# Run the migration
UP: >


# Reverse the migration
DOWN: >


YML;

        return $yaml;
    }

    public static function getDirectory()
    {
        return getcwd().'/database/migrations';
    }

    public static function getGeneratedVersion()
    {
        $finder = new Finder();
        $finder->files()->in(self::getDirectory());

        $versions = ['000'];

        foreach ($finder as $file) {
            $filename = $file->getRelativePathname();

            list($version, $description) = explode('_', $filename);
            $versions[] =  $version;
        }

        $last = end($versions);
        $new  = (int) $last + 1;

        return str_pad($new, 3, '0', STR_PAD_LEFT);
    }

    public static function getGeneratedFilename($argument)
    {
        $version = self::getGeneratedVersion();

        return $version.'_'.strtolower($argument).'.yml';
    }

    public static function getAllFiles()
    {
        $finder = new Finder();

        return $finder->files()->in(self::getDirectory());
    }

    public static function getFileInfo($file)
    {
        list($version) = explode('_', $file);

        $description = str_replace('_', ' ', substr($file, 4, -4));

        return [
            'version'     => $version,
            'description' => $description,
{'fraction_non_alphanumeric': 0.15353061822443598, 'fraction_numerical': 0.004687957808379725, 'mean_word_length': 2.2514285714285713, 'pattern_counts': {'":': 0, '<': 15, '<?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': '3259385', 'n_tokens_mistral': 1050, 'n_tokens_neox': 1003, 'n_words': 232}