Last active
December 17, 2017 14:06
-
-
Save darkin1/0d646bbc1a9db817e9e66d5c1ed96d8b 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 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