-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.php
71 lines (54 loc) · 1.99 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
59
60
61
62
63
64
65
66
67
68
69
70
<?php
require_once __DIR__ . '/../vendor/autoload.php';
#List the EU countries and show each country object
use swffm\EUCountries\EUCountriesIterator;
use swffm\EUCountries\EUCountryFactory;
$countryIterator = new EUCountriesIterator();
foreach( $countryIterator as $country ){
print ((int)$countryIterator->key() + 1) . ". " . $country->iso . " | " . $country->nameEnglish . "<br>";
$factoryCountry = EUCountryFactory::generate( $country->iso );
print json_encode( $factoryCountry );
print "\n\n<br><br>";
}
# Use Germany
$country = EUCountryFactory::generate( 'de' );
# Exception testing
// EUCountryFactory::generate('us');
// print "\n\n<br><br>";
# CALCULATIONS
# Gross from net
use swffm\EUCountries\Calc\GrossFromNet;
$calculator = new GrossFromNet( $country );
$result = $calculator->calc( '1' )->getResult();
print $result;
print "\n<br>";
print 'VAT:' . $calculator->getVat();
print "\n<br>";
print 'NET:' . $calculator->getNet();
print "\n<br>";
print 'GROSS:' . $calculator->getGross();
print "\n\n<br><br>";
# Net from gross
use swffm\EUCountries\Calc\NetFromGross;
$calculator = new NetFromGross( $country );
$result = $calculator->calc( $result )->getResult();
print $result;
print "\n<br>";
print 'VAT:' . $calculator->getVat();
print "\n<br>";
print 'NET:' . $calculator->getNet();
print "\n<br>";
print 'GROSS:' . $calculator->getGross();
print "\n\n<br><br>";
#Calculation of the monetary value from country to country
use swffm\EUCountries\Calc\CurrencyCountryToCountry;
$country2 = EUCountryFactory::generate( 'hu' );
$calculator = new CurrencyCountryToCountry( $country, $country2 );
$result = $calculator->calc( '1' )->getResult();
print $result . ' ' . $country2->currencySymbol;
print "\n\n<br><br>";
#Calculation of the distance between two countries from center lat/lon to center lat/lon
use swffm\EUCountries\Calc\DistanceCountryToCountry;
$calculator = new DistanceCountryToCountry( $country, $country2 );
print $calculator->getResult() . ' km';
print "\n\n<br><br>";