isCli()) { $helper->log('This example should only be run from a Web Browser' . PHP_EOL); return; } $negatives = [ CurrencyNegative::minus, CurrencyNegative::redMinus, CurrencyNegative::parentheses, CurrencyNegative::redParentheses, ]; $negativesString = [ 'CurrencyNegative::minus', 'CurrencyNegative::redMinus', 'CurrencyNegative::parentheses', 'CurrencyNegative::redParentheses', ]; $currencies = [ '$' => 'US Dollars ($)', '€' => 'Euro (€)', '¥' => 'Japanese Yen (¥)', '£' => 'Pound Sterling (£)', '₹' => 'Rupee (₹)', '₽' => 'Rouble (₽)', ]; ?>
log('The Sample Number Value must be numeric'); } elseif (!is_numeric($_POST['decimals']) || str_contains((string) $_POST['decimals'], '.') || (int) $_POST['decimals'] < 0) { $helper->log('The Decimal Places value must be positive integer'); } elseif (!in_array($_POST['currency'], array_keys($currencies), true)) { $helper->log('Unrecognized currency symbol'); } else { try { $negative = $negatives[$_POST['negative']] ?? CurrencyNegative::minus; $wizard = new Wizard\Currency($_POST['currency'], (int) $_POST['decimals'], isset($_POST['thousands']), (bool) $_POST['position']); $wizard->setNegative($negative); $mask = $wizard->format(); $example = (string) NumberFormat::toFormattedString((float) $_POST['number'], $mask, [HtmlWriter::class, 'formatColorStatic']); $helper->log('