ah-b / oil
flexible package for manage complex domain logic
0.1
2019-05-31 12:18 UTC
Requires (Dev)
- phpunit/phpunit: ^7.5
This package is auto-updated.
Last update: 2025-01-29 06:13:38 UTC
README
composer require ah-b/oil "0.1"
Usage
$pipelineService = new OilService(new Pipeline()); $pipelineService->add(new Test()); $pipelineService->run('my payload');
class Test { public function __invoke($payload) { return $payload; } }
mediate
$pipelineService = new OilService(new Mediator()); $pipelineService->add(function($payload){ echo $payload; }); $pipelineService->run('my payload');
Scenario
public function indexController() { $databaseRecord = "test"; if($databaseRecord == "test") { // do some logic } if($databaseRecord == "foo") { // do some logic } if($databaseRecord == "bar") { // do some logic } ... }
public function indexController() { $databaseRecord = "test"; $pipelineService = new OilService(new Pipeline()); $pipelineService->add(new Test()); $pipelineService->add(new Foo()); $pipelineService->add(new Bar()); $pipelineService->run($databaseRecord); ... }