Skip to content

Commit

Permalink
Update app example for demo of Casting.
Browse files Browse the repository at this point in the history
  • Loading branch information
hakre committed Sep 12, 2012
1 parent 4915fdd commit 8beb96e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions example/app.php
Expand Up @@ -13,3 +13,24 @@

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());


0 comments on commit 8beb96e

Please sign in to comment.