Skip to content

Commit d6e9271

Browse files
Final project commit
0 parents  commit d6e9271

15 files changed

+1107
-0
lines changed

README.md

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
currency-converter-php
2+
======================
3+
4+
PHP global currency converter using fixer.io API (include bitcoin, silver and gold).
5+
6+
## Getting Started
7+
8+
```php
9+
<?php
10+
11+
require __DIR__ .'/vendor/autoload.php';
12+
13+
$value = new CConverter\Converter('YOUR_API_KEY');
14+
echo $value->cconv('EUR', 'USD'); // print for ex. 1.20303 (EUR -> USD)
15+
16+
// set amount
17+
18+
echo $value->cconv('EUR', 'USD', 10.20); // print for ex. 12.270906 (10.20 EUR -> USD)
19+
20+
// set output digits number (with round up)
21+
22+
echo $value->cconv('EUR', 'USD', 1, 4); // print for ex. 1.2030 (EUR -> USD)
23+
echo $value->cconv('EUR', 'USD', 1, 2); // print for ex. 1.20 (EUR -> USD)
24+
25+
// convert by country short name
26+
27+
echo $value->cconv('DE', 'USD'); // print for ex. 1.20303 (EUR -> USD)
28+
echo $value->cconv('DE', 'PL'); // print for ex. 4.20394 (EUR -> PLN)
29+
echo $value->cconv('HU', 'JP'); // print for ex. 400.30203 (HUF -> JPY)
30+
31+
// convert for gold, sliver or bitcoin
32+
33+
echo $value->cconv('EUR', 'BTC'); // print for ex. 0.00023 (EUR -> BTC) [BTC bitcoin]
34+
echo $value->cconv('USD', 'XAU'); // print for ex. 0.00223 (USD -> XAU) [XAU gold]
35+
echo $value->cconv('USD', 'XAU'); // print for ex. 0.00421 (USD -> XAG) [XAG silver]
36+
37+
// convert currency using array
38+
39+
$array = $value->cconv(array('EUR','PLN'), 'USD');
40+
var_dump($array);
41+
/*
42+
var_dump($array) returns:
43+
EUR -> USD
44+
PLN -> USD
45+
..array
46+
*/
47+
$array = $value->cconv(array('EUR','PLN'), array('USD', 'GBP'));
48+
var_dump($array);
49+
/*
50+
var_dump($array) returns:
51+
EUR -> USD
52+
EUR -> GBP
53+
PLN -> USD
54+
PLN -> GBP
55+
..array
56+
*/
57+
$array = $value->cconv('EUR', array('USD', 'GBP'));
58+
var_dump($array);
59+
/*
60+
var_dump($array) returns:
61+
EUR -> USD
62+
EUR -> GBP
63+
..array
64+
*/
65+
66+
```
67+
68+
## Caching currency
69+
70+
```php
71+
<?php
72+
73+
require __DIR__ .'/vendor/autoload.php';
74+
75+
$value = new CConverter\Converter('YOUR_API_KEY');
76+
$value->cache(true); // set this for enable caching, default cache time is 60 minutes
77+
echo $value->cconv('EUR', 'USD');
78+
79+
// change cache time
80+
$value = new CConverter\Converter('YOUR_API_KEY');
81+
$value->cache(true, 10); // set this for enable caching and set 10 minutes cache file
82+
echo $value->cconv('EUR', 'USD');
83+
84+
```
85+
86+
## Requirements
87+
88+
* PHP version 5.5 or later
89+
90+
## Usage
91+
92+
Please look into GETING STARTED section.
93+
You can combine the examples shown above.
94+
95+
```php
96+
<?php
97+
98+
require __DIR__ .'/vendor/autoload.php';
99+
100+
$value = new CConverter\Converter('YOUR_API_KEY');
101+
$array = $value->cconv(array('DE','EUR', 'USD', 10.20304, 3);
102+
103+
```
104+
105+
## Installation
106+
107+
This library depends on composer for installation . For installation of composer, please visit [getcomposer.org](//getcomposer.org).
108+
Installation using a composer:
109+
110+
```
111+
composer require PatrykKosiba/currency-converter
112+
```
113+
114+
or download .zip for create vendor file.
115+
116+
## Why Use It
117+
118+
* Relaible Rates with fixer.io API
119+
* Over 160 currencies
120+
* Support for gold, silver and bitcoin exchange rates
121+
* Caching of rate, to avoid connecting to fixer.io multiple times
122+
* Conversion without currency code by country short code
123+
* Conversion of many currencies with one API reference
124+
125+
## Authors
126+
127+
MSc Patryk Kosiba
128+
See profile on linkedin (https://www.linkedin.com/in/patryk-kosiba/)
129+
130+
## License
131+
132+
This project is licensed under the MIT License.

composer.json

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "patrykkosiba/ccconverter",
3+
"description": "PHP global currency converter using fixer.io API (include bitcoin, silver and gold)",
4+
"license": "MIT",
5+
"keywords": [
6+
"api",
7+
"bitcoin",
8+
"btc",
9+
"currency",
10+
"currencyconverter",
11+
"currency-converter",
12+
"converter",
13+
"country",
14+
"exchange-rates",
15+
"fixer",
16+
"gold",
17+
"money",
18+
"silver"
19+
],
20+
"autoload": {
21+
"psr-4": { "CConverter\\": "src/" }
22+
},
23+
"authors": [
24+
{
25+
"name": "mgr inż. Patryk Kosiba",
26+
"email": "patryk.kosiba@gmail.com"
27+
}
28+
],
29+
"require": {
30+
"php": ">=5.5"
31+
}
32+
}

docs/README.md

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
currency-converter-php
2+
======================
3+
4+
PHP global currency converter using fixer.io API (include bitcoin, silver and gold).
5+
6+
## Getting Started
7+
8+
```php
9+
<?php
10+
11+
require __DIR__ .'/vendor/autoload.php';
12+
13+
$value = new CConverter\Converter('YOUR_API_KEY');
14+
echo $value->cconv('EUR', 'USD'); // print for ex. 1.20303 (EUR -> USD)
15+
16+
// set amount
17+
18+
echo $value->cconv('EUR', 'USD', 10.20); // print for ex. 12.270906 (10.20 EUR -> USD)
19+
20+
// set output digits number (with round up)
21+
22+
echo $value->cconv('EUR', 'USD', 1, 4); // print for ex. 1.2030 (EUR -> USD)
23+
echo $value->cconv('EUR', 'USD', 1, 2); // print for ex. 1.20 (EUR -> USD)
24+
25+
// convert by country short name
26+
27+
echo $value->cconv('DE', 'USD'); // print for ex. 1.20303 (EUR -> USD)
28+
echo $value->cconv('DE', 'PL'); // print for ex. 4.20394 (EUR -> PLN)
29+
echo $value->cconv('HU', 'JP'); // print for ex. 400.30203 (HUF -> JPY)
30+
31+
// convert for gold, sliver or bitcoin
32+
33+
echo $value->cconv('EUR', 'BTC'); // print for ex. 0.00023 (EUR -> BTC) [BTC bitcoin]
34+
echo $value->cconv('USD', 'XAU'); // print for ex. 0.00223 (USD -> XAU) [XAU gold]
35+
echo $value->cconv('USD', 'XAU'); // print for ex. 0.00421 (USD -> XAG) [XAG silver]
36+
37+
// convert currency using array
38+
39+
$array = $value->cconv(array('EUR','PLN'), 'USD');
40+
var_dump($array);
41+
/*
42+
var_dump($array) returns:
43+
EUR -> USD
44+
PLN -> USD
45+
..array
46+
*/
47+
$array = $value->cconv(array('EUR','PLN'), array('USD', 'GBP'));
48+
var_dump($array);
49+
/*
50+
var_dump($array) returns:
51+
EUR -> USD
52+
EUR -> GBP
53+
PLN -> USD
54+
PLN -> GBP
55+
..array
56+
*/
57+
$array = $value->cconv('EUR', array('USD', 'GBP'));
58+
var_dump($array);
59+
/*
60+
var_dump($array) returns:
61+
EUR -> USD
62+
EUR -> GBP
63+
..array
64+
*/
65+
66+
```
67+
68+
## Caching currency
69+
70+
```php
71+
<?php
72+
73+
require __DIR__ .'/vendor/autoload.php';
74+
75+
$value = new CConverter\Converter('YOUR_API_KEY');
76+
$value->cache(true); // set this for enable caching, default cache time is 60 minutes
77+
echo $value->cconv('EUR', 'USD');
78+
79+
// change cache time
80+
$value = new CConverter\Converter('YOUR_API_KEY');
81+
$value->cache(true, 10); // set this for enable caching and set 10 minutes cache file
82+
echo $value->cconv('EUR', 'USD');
83+
84+
```
85+
86+
## Requirements
87+
88+
* PHP version 5.5 or later
89+
90+
## Usage
91+
92+
Please look into GETING STARTED section.
93+
You can combine the examples shown above.
94+
95+
```php
96+
<?php
97+
98+
require __DIR__ .'/vendor/autoload.php';
99+
100+
$value = new CConverter\Converter('YOUR_API_KEY');
101+
$array = $value->cconv(array('DE','EUR', 'USD', 10.20304, 3);
102+
103+
```
104+
105+
## Installation
106+
107+
This library depends on composer for installation . For installation of composer, please visit [getcomposer.org](//getcomposer.org).
108+
Installation using a composer:
109+
110+
```
111+
composer require PatrykKosiba/currency-converter
112+
```
113+
114+
or download .zip for create vendor file.
115+
116+
## Why Use It
117+
118+
* Relaible Rates with fixer.io API
119+
* Over 160 currencies
120+
* Support for gold, silver and bitcoin exchange rates
121+
* Caching of rate, to avoid connecting to fixer.io multiple times
122+
* Conversion without currency code by country short code
123+
* Conversion of many currencies with one API reference
124+
125+
## Authors
126+
127+
MSc Patryk Kosiba
128+
See profile on linkedin (https://www.linkedin.com/in/patryk-kosiba/)
129+
130+
## License
131+
132+
This project is licensed under the MIT License.

0 commit comments

Comments
 (0)