Created
January 31, 2022 19:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace App\Providers; | |
use Illuminate\Support\ServiceProvider; | |
use App\Pseudo\Filters\FilterInterface; | |
use App\Pseudo\Filters\FilterClassOne; | |
use App\Pseudo\Filters\FilterClassTwo; | |
use App\Pseudo\Filters\FilterClassThree; | |
use App\Pseudo\Filters\FilterClassFour; | |
class AppServiceProvider extends ServiceProvider | |
{ | |
public function register(): void | |
{ | |
$this->app->bind( | |
FilterInterface::class, | |
static fn (Container $container): array => [ | |
$container->make(FilterClassOne::class), | |
$container->make(FilterClassTwo::class), | |
$container->make(FilterClassThree::class), | |
$container->make(FilterClassFour::class), | |
] | |
); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace App\Pseudo; | |
use App\Pseudo\Filters\FilterInterface; | |
class Runner | |
{ | |
protected array $filters = []; | |
public function __construct(FilterInterface ...$filters) | |
{ | |
$this->filters = $filters; | |
} | |
public function run($data) | |
{ | |
return app(Pipeline::class) | |
->send($data) | |
->through($this->pipes) | |
->thenReturn(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment