<commit_before><?php namespace PhpSpec\Laravel\Util;

use ErrorException;
use Illuminate\Foundation\Application;

/**
 * This class provides an entry point into Laravel for PhpSpec.
 */
class Laravel {

    /**
     * The Illuminate application instance.
     *
     * @var \Illuminate\Foundation\Application
     */
    private $app;

    /**
     * The Laravel testing environment.
     *
     * @var string
     */
    private $env;

    /**
     * Path to the Laravel bootstrap dir.
     *
     * @var string
     */
    private $bootstrapPath;

    /**
     * Whether or not to migrate the database after booting Laravel.
     *
     * @var boolean
     */
    private $migrateDatabase;

    /**
     * Constructor.
     *
     * Setup application on construct.
     *
     * @param string  $env             Laravel testing environment. 'testing' by default
     * @param string  $bootstrapPath   Path to the Laravel bootstrap dir
     * @param boolean $migrateDatabase Whether or not to run db migrations after
     *                                 bootstrapping. False by default
     * @param mixed                    @see refreshApplication()
     * @return void
     */
    public function __construct($env, $bootstrapPath, $migrateDatabase = false, $app = null)
    {
        $this->env = $env ?: 'testing';
        $this->bootstrapPath = $bootstrapPath;
        $this->migrateDatabase = $migrateDatabase;

        $this->refreshApplication($app);
    }

    /**
     * Refresh the application instance.
     *
     * @param \Illuminate\Foundation\Application $app Optionally provide your own unbooted
     *                                                Laravel Application instance. This
     *                                                parameter can largely be ignored and
     *                                                is used just for unit testing
     * @return void
     */
    public function refreshApplication($app = null)
    {
        $this->app = $app instanceof Application ? $app : $this->createApplication();

        $this->app->setRequestForConsoleEnvironment();

        $this->app->boot();

        if ($this->migrateDatabase) {
            $artisan = $this->app->make('artisan');

            try {
                $artisan->call('migrate:install');
            } catch (\Illuminate\Database\QueryException $e) {
                // migration table is already installed<commit_msg>include queryexception at the top<commit_after><?php namespace PhpSpec\Laravel\Util;

use ErrorException;
use Illuminate\Database\QueryException;
use Illuminate\Foundation\Application;

/**
 * This class provides an entry point into Laravel for PhpSpec.
 */
class Laravel {

    /**
     * The Illuminate application instance.
     *
     * @var \Illuminate\Foundation\Application
     */
    private $app;

    /**
     * The Laravel testing environment.
     *
     * @var string
     */
    private $env;

    /**
     * Path to the Laravel bootstrap dir.
     *
     * @var string
     */
    private $bootstrapPath;

    /**
     * Whether or not to migrate the database after booting Laravel.
     *
     * @var boolean
     */
    private $migrateDatabase;

    /**
     * Constructor.
     *
     * Setup application on construct.
     *
     * @param string  $env             Laravel testing environment. 'testing' by default
     * @param string  $bootstrapPath   Path to the Laravel bootstrap dir
     * @param boolean $migrateDatabase Whether or not to run db migrations after
     *                                 bootstrapping. False by default
     * @param mixed                    @see refreshApplication()
     * @return void
     */
    public function __construct($env, $bootstrapPath, $migrateDatabase = false, $app = null)
    {
        $this->env = $env ?: 'testing';
        $this->bootstrapPath = $bootstrapPath;
        $this->migrateDatabase = $migrateDatabase;

        $this->refreshApplication($app);
    }

    /**
     * Refresh the application instance.
     *
     * @param \Illuminate\Foundation\Application $app Optionally provide your own unbooted
     *                                                Laravel Application instance. This
     *                                                parameter can largely be ignored and
     *                                                is used just for unit testing
     * @return void
     */
    public function refreshApplication($app = null)
    {
        $this->app = $app instanceof Application ? $app : $this->createApplication();

        $this->app->setRequestForConsoleEnvironment();

        $this->app->boot();

        if ($this->migrateDatabase) {
            $artisan = $this->app->make('artisan');

            try {
                $artisan->call('migrate:install');
            } catch (QueryException $e) {
                // migration table is already installed
{'fraction_non_alphanumeric': 0.09732161112246984, 'fraction_numerical': 0.0, 'mean_word_length': 1.7638418079096045, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3730159', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1216, 'n_words': 355}