<commit_before><?php

namespace TheCrypticAce\Suitey;

use Illuminate\Pipeline\Pipeline;
use Illuminate\Support\Collection;
use Illuminate\Contracts\Container\Container;

class Suitey
{
    /**
     * A list of all executable steps
     *
     * @var \Illuminate\Support\Collection
     */
    private $steps;

    /**
     * A container used to resolve dependencies
     *
     * @var \Illuminate\Contracts\Container\Container
     */
    private $container;

    public function __construct(Container $container)
    {
        $this->steps = new Collection;
        $this->container = $container;
    }

    public function add($steps)
    {
        $this->steps = $this->steps->merge(array_wrap($steps));
    }

    public function fresh()
    {
        return tap(clone $this, function ($instance) {
            $instance->steps = new Collection;
        });
    }

    public function run(IO $io)
    {
        return Process::usingOutput($io->output(), function () use ($io) {
            return $this->pipeline()->send($io)->then(function ($io) {
                return 0;
            });
        });
    }

    private function pipeline()
    {
        $pipeline = new Pipeline($this->container);

        return $pipeline->through($this->pending()->all());
    }

    private function pending()
    {
        return $this->steps->map(function ($step, $index) {
            return new PendingStep($step, 1 + $index, $this->steps->count());
        });
    }
}<commit_msg>Use laravel application instance when running suitey<commit_after><?php

namespace TheCrypticAce\Suitey;

use Illuminate\Pipeline\Pipeline;
use Illuminate\Support\Collection;
use Illuminate\Contracts\Foundation\Application;

class Suitey
{
    /**
     * The laravel application instance
     * A container used to resolve dependencies
     *
     * @var \Illuminate\Contracts\Foundation\Application
     */
    private $app;

    /**
     * A list of all executable steps
     *
     * @var \Illuminate\Support\Collection
     */
    private $steps;

    public function __construct(Application $app)
    {
        $this->app = $app;
        $this->steps = new Collection;
    }

    public function add($steps)
    {
        $this->steps = $this->steps->merge(array_wrap($steps));
    }

    public function fresh()
    {
        return tap(clone $this, function ($instance) {
            $instance->steps = new Collection;
        });
    }

    public function run(IO $io)
    {
        return Process::usingOutput($io->output(), function () use ($io) {
            return $this->pipeline()->send($io)->then(function ($io) {
                return 0;
            });
        });
    }

    private function pipeline()
    {
        $pipeline = new Pipeline($this->app);

        return $pipeline->through($this->pending()->all());
    }

    private function pending()
    {
        return $this->steps->map(function ($step, $index) {
            return new PendingStep($step, 1 + $index, $this->steps->count());
        });
    }
}
{'fraction_non_alphanumeric': 0.1383084577114428, 'fraction_numerical': 0.0013266998341625207, 'mean_word_length': 2.23952738990333, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, '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': '1821723', 'n_tokens_mistral': 845, 'n_tokens_neox': 843, 'n_words': 192}