Created
June 3, 2017 20:43
-
-
Save aguimaraes/8268e12cb18d41137c55b2ad98f6f9e8 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 | |
namespace App\Domain; | |
class Checkout | |
{ | |
private $orderValidation; | |
private $orderRepo; | |
private $featureToggle; | |
public function __construct( | |
OrderValidation $orderValidation, | |
OrderRepository $orderRepo, | |
FeatureToggle $featureToggle | |
) { | |
$this->orderValidation = $orderValidation; | |
$this->orderRepo = $orderRepo; | |
$this->featureToggle = $featureToggle; | |
} | |
public function saveOrder(Order $order): Order | |
{ | |
$this->orderValidation->validate($order); | |
$this->callFraudDetection($order); | |
return $this->orderRepo->save($order); | |
} | |
public function callFraudDetection(Order $order): void | |
{ | |
// se o feature toggle estiver desabilitado, retorna sem fazer nada | |
if (!$this->featureToggle->isFraudDetectionEnabled()) { | |
return; | |
} | |
$this->isFraud(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment