<commit_before><?php

use Orchestra\Testbench\Foundation\Application;
use Orchestra\Testbench\Foundation\Bootstrap\LoadEnvironmentVariablesFromArray;
use Orchestra\Testbench\Foundation\Config;

/**
 * Create Laravel application.
 *
 * @return \Illuminate\Foundation\Application
 */
$createApp = function () {
    $workingPath = realpath(__DIR__.'/../');
    $config = Config::loadFromYaml($workingPath);

    if (empty($config['env'])) {
        $APP_KEY = $_SERVER['APP_KEY'] ?? $_ENV['APP_KEY'] ?? '<KEY>';
        $DB_CONNECTION = $_SERVER['DB_CONNECTION'] ?? $_ENV['DB_CONNECTION'] ?? 'testing';

        $config['env'] = ['APP_KEY="'.$APP_KEY.'"', 'APP_DEBUG=(true)', 'DB_CONNECTION="'.$DB_CONNECTION.'"'];
    }

    $hasEnvironmentFile = file_exists("{$workingPath}/.env");

    /** @var \Illuminate\Foundation\Application $app */
    return Application::create(
        basePath: $config['laravel'],
        resolvingCallback: function ($app) use ($config, $hasEnvironmentFile) {
            if ($hasEnvironmentFile === false) {
                (new LoadEnvironmentVariablesFromArray($config['env'] ?? []))->bootstrap($app);
            }
        },
        options: ['enables_package_discoveries' => $hasEnvironmentFile, 'extra' => $config->getExtraAttributes()],
    );
};

$app = $createApp();

/** @var \Illuminate\Routing\Router $router */
$router = $app->make('router');

unset($createApp);

collect(glob(__DIR__.'/../routes/testbench-*.php'))
    ->each(function ($routeFile) use ($app, $router) {
        require $routeFile;
    });

return $app;<commit_msg>wip<commit_after><?php

use Orchestra\Testbench\Foundation\Application;
use Orchestra\Testbench\Foundation\Bootstrap\LoadEnvironmentVariablesFromArray;
use Orchestra\Testbench\Foundation\Config;

/**
 * Create Laravel application.
 *
 * @param  string  $workingPath
 * @return \Illuminate\Foundation\Application
 */
$createApp = function (string $workingPath) {
    $config = Config::loadFromYaml($workingPath);

    if (empty($config['env'])) {
        $APP_KEY = $_SERVER['APP_KEY'] ?? $_ENV['APP_KEY'] ?? '<KEY>';
        $DB_CONNECTION = $_SERVER['DB_CONNECTION'] ?? $_ENV['DB_CONNECTION'] ?? 'testing';

        $config['env'] = ['APP_KEY="'.$APP_KEY.'"', 'APP_DEBUG=(true)', 'DB_CONNECTION="'.$DB_CONNECTION.'"'];
    }

    $hasEnvironmentFile = file_exists("{$workingPath}/.env");

    /** @var \Illuminate\Foundation\Application $app */
    return Application::create(
        basePath: $config['laravel'],
        resolvingCallback: function ($app) use ($config, $hasEnvironmentFile) {
            if ($hasEnvironmentFile === false) {
                (new LoadEnvironmentVariablesFromArray($config['env'] ?? []))->bootstrap($app);
            }
        },
        options: ['enables_package_discoveries' => $hasEnvironmentFile, 'extra' => $config->getExtraAttributes()],
    );
};

$app = $createApp(realpath(__DIR__.'/../'));

/** @var \Illuminate\Routing\Router $router */
$router = $app->make('router');

unset($createApp);

collect(glob(__DIR__.'/../routes/testbench-*.php'))
    ->each(function ($routeFile) use ($app, $router) {
        require $routeFile;
    });

return $app;
{'fraction_non_alphanumeric': 0.1903409090909091, 'fraction_numerical': 0.0, 'mean_word_length': 3.920807453416149, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, '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': '484106', 'n_tokens_mistral': 943, 'n_tokens_neox': 953, 'n_words': 154}