Created
March 2, 2017 14:16
-
-
Save joereynolds/9370229e04e78d6c9af971bcdb7a3200 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 | |
interface PaymentProvider | |
{ | |
public function purchase(); | |
} | |
class BrainTreePaymentProvider implements PaymentProvider | |
{ | |
public function purchase() | |
{ | |
var_dump('Purchasing through Brain tree'); | |
} | |
} | |
class SagePayPaymentProvider implements PaymentProvider | |
{ | |
public function purchase() | |
{ | |
var_dump('Purchasing through Sagepay'); | |
} | |
} | |
class Booking | |
{ | |
public function create(PaymentProvider $paymentProvider) | |
{ | |
$paymentProvider->purchase(); | |
} | |
} | |
$booking = new Booking(); | |
$booking->create(new BrainTreePaymentProvider); | |
$booking->create(new SagePayPaymentProvider); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment