Created
September 5, 2019 13:26
-
-
Save kobus1998/04fc4626acdd95f41ba70e7ed71b2a40 to your computer and use it in GitHub Desktop.
flow pattern
This file contains hidden or 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 | |
interface Flow | |
{ | |
public function execute(); | |
} | |
class PaymentCheckout implements Flow | |
{ | |
public function __construct($manadtoryParameters) | |
{ | |
} | |
public function tokenize() | |
{ | |
} | |
public function saveCard() | |
{ | |
} | |
public function charge() | |
{ | |
} | |
public function redirect() | |
{ | |
} | |
public function error() | |
{ | |
} | |
public function execute() | |
{ | |
if (!$this->saveCard()) { | |
return $this->error(); | |
} | |
if (!$this->tokenize()) { | |
return $this->error(); | |
} | |
if (!$this->charge()) { | |
return $this->error(); | |
} | |
if (!$this->redirect()) { | |
return $this->error(); | |
} | |
} | |
} | |
(new PaymentCheckout($user, $card, $payment))->execute(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment