<?php
namespace App\Features;

use App\Features\FirstTask;
use App\Features\SecondTask;
use Illuminate\Pipeline\Pipeline;

// *Naming things is hard* ... So, this is a class called `ProcessClass` that `run()` some text ¯\_(ツ)_/¯

class ProcessClass
{
    protected $pipes;

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

    public function loadPipes()
    {
        return [
            FirstTask::class,
            SecondTask::class
        ];
    }

    public function run($text)
    {
        return app(Pipeline::class)
            ->send($text)
            ->through($this->pipes)
            ->then(function ($text) {
                return $text . "finally";
            });
    }
}