Skip to content

Instantly share code, notes, and snippets.

@kobus1998
Created September 5, 2019 13:26
Show Gist options
  • Save kobus1998/04fc4626acdd95f41ba70e7ed71b2a40 to your computer and use it in GitHub Desktop.
Save kobus1998/04fc4626acdd95f41ba70e7ed71b2a40 to your computer and use it in GitHub Desktop.
flow pattern
<?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