Skip to content

Instantly share code, notes, and snippets.

@darkin1
Last active December 17, 2017 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darkin1/0d646bbc1a9db817e9e66d5c1ed96d8b to your computer and use it in GitHub Desktop.
Save darkin1/0d646bbc1a9db817e9e66d5c1ed96d8b to your computer and use it in GitHub Desktop.
<?php
interface PaymentContract
{
public function payment();
}
class Cash implements PaymentContract
{
public function payment()
{
return 'cash';
}
}
class CreditCard implements PaymentContract
{
public function payment()
{
return 'creadit card';
}
}
class Bitcoin implements PaymentContract
{
public function payment()
{
return 'bitcoin';
}
}
class Checkout
{
public function begin(PaymentContract $checkout)
{
return $checkout->payment();
}
}
$checkout = new Checkout();
echo $checkout->begin(new CreditCard());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment