Skip to content

Instantly share code, notes, and snippets.

@joereynolds
Created March 2, 2017 14:16
Show Gist options
  • Save joereynolds/9370229e04e78d6c9af971bcdb7a3200 to your computer and use it in GitHub Desktop.
Save joereynolds/9370229e04e78d6c9af971bcdb7a3200 to your computer and use it in GitHub Desktop.
<?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