Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: ScalaCopy
37 lines (24 sloc) 0.796 kb
* DCI Account Example in PHP
* Example Stub Application invoking DCI
* @author hakre
require __DIR__ . '/../src/autoloader.php';
header("Content-Type: text/plain");
print "DCI Account Example in PHP\n";
print "==========================\n";
Use DCI\Casting;
Use App\SavingsAccount;
Use App\CheckingAccount;
Use App\Currency;
$casting = new Casting();
$source = new SavingsAccount;
$casting->setRoleAndScript('MoneySource', 'TransferMoneySource')->castOf($source);
$sink = new CheckingAccount;
$casting->setRoleAndScript('MoneySink', 'TransferMoneySink')->castOf($sink);
$source->increaseBalance(new Currency(100000));
$source->transferTo(new Currency(200), $sink);
printf("Source: %s: Sink: %s\n", $source->getAvailableBalance(), $sink->getAvailableBalance());
Jump to Line
Something went wrong with that request. Please try again.