Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface PaymentInterface
- {
- public function pay(PaymentRequest $request);
- }
- class Payment implements PaymentInterface
- {
- public function pay(PaymentRequest $request)
- {
- if ($request->isFirstPayment()) {
- $this->firstPayment->pay($request);
- } else {
- $this->tokenPayment->pay($request);
- }
- }
- }
- $payment->pay($paymentRequest);
- class PaymentFactory
- {
- public static function choosePayment(PaymentRequest $request)
- {
- if ($request->isFirstPayment()) {
- return new FirstPayment();
- }
- return new TokenPayment();
- }
- }
- $payment = PaymentFactory::choosePayment($paymentRequest);
- $payment->pay($paymentRequest);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement