Created
October 4, 2018 00:38
-
-
Save jorgecc/f2c2d8eca76e99e2bdf2d4a1df3ccf92 to your computer and use it in GitHub Desktop.
Example of DI
This file contains hidden or 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 | |
$obj=new ClassConvertMoneyWithInjection(); | |
echo "converting 300 dollars to euro:<br>"; | |
$obj->setService(new ServiceDollarToEuro()); | |
$obj->example(300); | |
echo "converting 300 euros to dollar:<br>"; | |
$obj->setService(new ServiceEuroToDollar()); | |
$obj->example(300); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment