Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 32738d8
Showing
12 changed files
with
628 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
composer.lock | ||
phpunit.xml | ||
vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
language: php | ||
|
||
php: | ||
- 5.5 | ||
- 5.5.9 | ||
- 5.6 | ||
- 7.0 | ||
- nightly | ||
- hhvm | ||
|
||
before_script: | ||
- composer selfupdate | ||
- composer --prefer-source --dev install | ||
|
||
script: | ||
- bin/phpunit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Florian Voutzinos | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Laravel Swap [![Build status][travis-image]][travis-url] [![Version][version-image]][version-url] [![PHP Version][php-version-image]][php-version-url] | ||
|
||
> Integrates [Swap](https://github.com/florianv/swap) with Laravel 5 | ||
## Installation | ||
|
||
Install the package via [Composer](https://getcomposer.org): | ||
|
||
```bash | ||
$ composer require florianv/laravel-swap | ||
``` | ||
|
||
## Configuration | ||
|
||
Register the service provider and the facade in your configuration: | ||
|
||
```php | ||
// config/app.php | ||
'providers' => [ | ||
Florianv\LaravelSwap\SwapServiceProvider::class | ||
], | ||
|
||
'aliases' => [ | ||
'Swap' => Florianv\LaravelSwap\Facades\Swap::class | ||
] | ||
``` | ||
|
||
Publish Swap's configuration: | ||
|
||
```bash | ||
$ php artisan vendor:publish | ||
``` | ||
|
||
By default, `Swap` is configured to use the `FileGetContentsHttpAdapter`, the `YahooFinanceProvider` provider and don't use a cache. | ||
|
||
For more informations about all possibilities including Laravel Cache integration, read the comments in the | ||
[configuration file](https://github.com/florianv/laravel-swap/blob/master/config/swap.php). | ||
|
||
## Usage | ||
|
||
### Via the Facade | ||
|
||
```php | ||
Route::get('/', function () { | ||
$rate = Swap::quote('EUR/USD'); | ||
}); | ||
``` | ||
|
||
### Via Injection | ||
|
||
```php | ||
use Swap\SwapInterface; | ||
|
||
Route::get('/', function (SwapInterface $swap) { | ||
$rate = $swap->quote('EUR/USD'); | ||
}); | ||
``` | ||
|
||
## License | ||
|
||
[MIT](https://github.com/florianv/laravel-swap/blob/master/LICENSE) | ||
|
||
[travis-url]: https://travis-ci.org/florianv/laravel-swap | ||
[travis-image]: http://img.shields.io/travis/florianv/laravel-swap.svg?style=flat | ||
|
||
[version-url]: https://packagist.org/packages/florianv/laravel-swap | ||
[version-image]: http://img.shields.io/packagist/v/florianv/laravel-swap.svg?style=flat | ||
|
||
[php-version-url]: https://packagist.org/packages/florianv/laravel-swap | ||
[php-version-image]: http://img.shields.io/badge/php-5.5+-ff69b4.svg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"name": "florianv/laravel-swap", | ||
"type": "library", | ||
"description": "Integrates Swap with Laravel 5", | ||
"keywords": [ | ||
"laravel", | ||
"currency", | ||
"money", | ||
"rate", | ||
"conversion", | ||
"exchange rates" | ||
], | ||
"homepage": "https://github.com/florianv/laravel-swap", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Florian Voutzinos", | ||
"email": "florian@voutzinos.com", | ||
"homepage": "http://florian.voutzinos.com" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"Florianv\\LaravelSwap\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Florianv\\LaravelSwap\\Tests\\": "tests/" | ||
} | ||
}, | ||
"require": { | ||
"php": ">=5.5.9", | ||
"illuminate/contracts": "5.0.*|5.1.*", | ||
"illuminate/support": "5.0.*|5.1.*", | ||
"illuminate/view": "5.0.*|5.1.*", | ||
"florianv/swap": "~2.1.0" | ||
}, | ||
"require-dev": { | ||
"graham-campbell/testbench": "~2.1" | ||
}, | ||
"config": { | ||
"bin-dir": "bin" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Laravel Swap. | ||
* | ||
* (c) Florian Voutzinos <florian@voutzinos.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
return [ | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Http Adapter | ||
|-------------------------------------------------------------------------- | ||
| | ||
| This option specifies a service id to use as http adapter | ||
| (defaults to FileGetContentsHttpAdapter). | ||
| | ||
*/ | ||
'http_adapter' => null, | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Providers | ||
|-------------------------------------------------------------------------- | ||
| | ||
| This option specifies the providers to use with their name as key and | ||
| their config as value. The providers will be wrapped in a ChainProvider | ||
| in the order they appear in this array. | ||
| | ||
| Here is the config spec for each provider: | ||
| | ||
| * "yahoo_finance", "google_finance", "european_central_bank", "webservicex" | ||
| "national_bank_of_romania" can be enabled with "true" as value. | ||
| | ||
| * 'open_exchange_rates' => [ | ||
| 'app_id' => 'secret', // Your app id | ||
| 'enterprise' => true, // True if your AppId is an enterprise one | ||
| ] | ||
| | ||
| * 'xignite' => [ | ||
| 'token' => 'secret', // The API token | ||
| ] | ||
| | ||
*/ | ||
|
||
'providers' => [ | ||
'yahoo_finance' => true, | ||
], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Cache | ||
|-------------------------------------------------------------------------- | ||
| | ||
| This option specifies which cache to use to store rate values and its ttl. | ||
| Currently only Illuminate cache is supported: | ||
| | ||
| 'cache' => [ | ||
| 'type' => 'illuminate', | ||
| 'store' => 'apc', // Name of the cache store | ||
| 'ttl' => 60 // Ttl in minutes (defaults to 0) | ||
| ], | ||
*/ | ||
'cache' => null, | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit colors="true" bootstrap="vendor/autoload.php"> | ||
<testsuite name="Laravel Swap Tests Suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Laravel Swap. | ||
* | ||
* (c) Florian Voutzinos <florian@voutzinos.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Florianv\LaravelSwap\Facades; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
|
||
/** | ||
* Facade for Swap. | ||
* | ||
* @author Florian Voutzinos <florian@voutzinos.com> | ||
*/ | ||
final class Swap extends Facade | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected static function getFacadeAccessor() | ||
{ | ||
return 'swap'; | ||
} | ||
} |
Oops, something went wrong.