Exemplo n.º 1
0
function testMoneyGetCoinsString($testArray)
{
    echo 'TEST: ' . __METHOD__ . PHP_EOL;
    foreach ($testArray as $input => $output) {
        try {
            $money = new Money($input);
            $money->exchangeMoney();
            echo '========' . PHP_EOL;
            echo $input . ' => ' . $output . PHP_EOL;
            echo $money->getCoinsString() . PHP_EOL;
            echo PHP_EOL;
        } catch (Exception $e) {
        }
    }
}
Exemplo n.º 2
0
<?php

include_once 'Class/Money.php';
include_once 'Class/View.php';
use MoneyChanger\Money;
use MoneyChanger\View;
$post = array();
if (!empty($_POST)) {
    $post = $_POST;
}
if (isset($post['money'])) {
    try {
        $decoded = mb_convert_encoding($post['money'], "utf-8", "HTML-ENTITIES");
        unset($post['money']);
        $money = new Money($decoded);
        $money->exchangeMoney();
        $exchangeString = $money->getCoinsString();
        View::getResponseView($exchangeString);
    } catch (Exception $e) {
        View::getErrorView($e->getMessage());
    }
} else {
    View::getInitialView();
}