/
app.php
36 lines (24 loc) · 796 Bytes
/
app.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
/**
* 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());