-
Notifications
You must be signed in to change notification settings - Fork 18
/
test.php
58 lines (47 loc) · 1.2 KB
/
test.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
// composer code:
// require __DIR__ . '/vendor/autoload.php';
// non-composer code (can run this in console immediately):
spl_autoload_register(
function ($className)
{
$ds = DIRECTORY_SEPARATOR;
$className = str_replace('js\\tools\\numbers2words', '', $className);
$className = str_replace('\\', $ds, $className);
$className = trim($className, $ds);
$path = __DIR__ . $ds . 'src' . $ds . $className . '.php';
if (!is_readable($path))
{
return false;
}
require $path;
return true;
},
true
);
// common code:
use js\tools\numbers2words\exceptions\SpellerException;
use js\tools\numbers2words\Speller;
try
{
echo Speller::spellCurrency(123.45, Speller::LANGUAGE_ENGLISH, Speller::CURRENCY_EURO), "\n\n";
foreach (Speller::getAcceptedLanguages() as $language)
{
for ($i = 10000; $i <= 1000000000; $i *= 10)
{
$number = (rand($i / 10, $i) / 100);
echo 'Number = ', $number, "\n";
foreach (Speller::getAcceptedCurrencies() as $currency)
{
echo $language, ' => ', $currency, ' = ', Speller::spellCurrency($number, $language, $currency), "\n";
}
echo "\n";
}
echo "\n";
}
}
catch (SpellerException $iae)
{
echo $iae->getMessage();
die(1);
}