Skip to content

Commit

Permalink
format関数という関数名がひどいので変えた
Browse files Browse the repository at this point in the history
- p.17
- `$usd()`
    - US Doller
    - `/100`も閉じ込めた
- Change Function Declaration
  • Loading branch information
wand2016 committed Aug 12, 2019
1 parent cb79591 commit e45fc20
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/index.php
Expand Up @@ -37,9 +37,9 @@ function statement($invoice, $plays)
return $result;
};

$format = function($aNumber) {
$usd = function($aNumber) {
$format = '$%.2f';
return sprintf($format, $aNumber);
return sprintf($format, $aNumber / 100);
};

// ----------------------------------------
Expand All @@ -52,11 +52,11 @@ function statement($invoice, $plays)
$volumeCredits += $volumeCreditsFor($perf);

// print line for this order
$result .= ' ' . $playFor($perf)['name']. ': ' . $format($amountFor($perf) / 100) . "(${perf['audience']} seats)" . PHP_EOL;
$result .= ' ' . $playFor($perf)['name']. ': ' . $usd($amountFor($perf)) . "(${perf['audience']} seats)" . PHP_EOL;
$totalAmount += $amountFor($perf);
}

$result .= 'Amount owed is ' . $format($totalAmount / 100) . PHP_EOL;
$result .= 'Amount owed is ' . $usd($totalAmount) . PHP_EOL;
$result .= "You earned ${volumeCredits} credits" . PHP_EOL;
return $result;
}

0 comments on commit e45fc20

Please sign in to comment.