Created
September 2, 2014 08:46
-
-
Save cbergau/3e2d676820234efa83ad to your computer and use it in GitHub Desktop.
Rule Engine Clean Architecture
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 | |
class ChangeLogisticPartnerInteractor | |
{ | |
/** @var ChangeLogisticPartnerValidator */ | |
private $changeLogisticPartnerValidator; | |
public function execute($changeToId) | |
{ | |
// High level Policy | |
if (!$this->changeLogisticPartnerValidator->isValid($changeToId)) { | |
// Error | |
} | |
// Success | |
} | |
} | |
interface ChangeLogisticPartnerValidator | |
{ | |
public function isValid($changeToId); | |
} | |
// Low level detail | |
class RuleEngineChangeLogisticPartnerValidator implements ChangeLogisticPartnerValidator | |
{ | |
private $ruleEngine; | |
public function isValid($changeToId) { | |
return $this->ruleEngine->execute(/*...*/); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment