Skip to content

Instantly share code, notes, and snippets.

@BinaryKitten
Created January 31, 2022 19:46
Show Gist options
  • Save BinaryKitten/27b34e013db2a15f534a6e8508a7b174 to your computer and use it in GitHub Desktop.
Save BinaryKitten/27b34e013db2a15f534a6e8508a7b174 to your computer and use it in GitHub Desktop.
<?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),
]
);
}
}
<?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