Skip to content

Instantly share code, notes, and snippets.

@jorgecc
Created October 4, 2018 00:38
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 jorgecc/f2c2d8eca76e99e2bdf2d4a1df3ccf92 to your computer and use it in GitHub Desktop.
Save jorgecc/f2c2d8eca76e99e2bdf2d4a1df3ccf92 to your computer and use it in GitHub Desktop.
Example of DI
<?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