Created
January 31, 2022 19:46
-
-
Save BinaryKitten/27b34e013db2a15f534a6e8508a7b174 to your computer and use it in GitHub Desktop.
This file contains 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 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