Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
chapdel committed Dec 9, 2021
0 parents commit 8fa77ec
Show file tree
Hide file tree
Showing 25 changed files with 2,493 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/vendor
composer.phar
composer.lock
.DS_Store
.idea
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
language: php

php:
- 7.2
- 7.3
- 7.4
- 8.0

before_script:
- curl -s http://getcomposer.org/installer | php
- php composer.phar install --dev

script:
- ./vendor/bin/phpcs --standard=phpcs.xml src
- ./vendor/bin/phpstan --level=0 --no-progress analyse src
11 changes: 11 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
The BSD 2-Clause License
Copyright (c) 2016-2020, Daniel Stainback
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# currency
57 changes: 57 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"name": "forexapi/currency",
"description": "This provides Laravel with currency functions such as currency formatting and conversion using up-to-date exchange rates.",
"keywords": [
"laravel",
"currency",
"money",
"exchange rate",
"OpenExchangeRates",
"Exchange Rates API",
"finance"
],
"license": "BSD-2-Clause",
"authors": [
{
"name": "Daniel Stainback",
"email": "[email protected]"
},
{
"name": "CHapdel KAMGA",
"email": "[email protected]"
}
],
"require": {
"php": "^7.2|^8.0",
"illuminate/support": "^6.0|^7.0|^8.0",
"illuminate/console": "^6.0|^7.0|^8.0",
"illuminate/cache": "^6.0|^7.0|^8.0"
},
"suggest": {
"illuminate/database": "Allows for storing of currencies in the database"
},
"require-dev": {
"phpunit/phpunit": "^8.0",
"mockery/mockery": "^1.3",
"phpstan/phpstan": "^0.12.14",
"squizlabs/php_codesniffer": "^3.5"
},
"autoload": {
"files": [
"src/helpers.php"
],
"psr-4": {
"ForexAPI\\Currency\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"ForexAPI\\Currency\\CurrencyServiceProvider"
],
"aliases": {
"Currency": "ForexAPI\\Currency\\Facades\\Currency"
}
}
}
}
121 changes: 121 additions & 0 deletions config/currency.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Application Currency
|--------------------------------------------------------------------------
|
| The application currency determines the default currency that will be
| used by the currency service provider. You are free to set this value
| to any of the currencies which will be supported by the application.
|
*/

'default' => 'USD',

/*
|--------------------------------------------------------------------------
| API Key for FOREXAPI
|--------------------------------------------------------------------------
|
| Only required if you with to use the Open Exchange Rates api. You can
| always just use Yahoo, the current default.
|
*/

'api_key' => env(
"FOREXAPI_KEY",
),

/*
|--------------------------------------------------------------------------
| Default Storage Driver
|--------------------------------------------------------------------------
|
| Here you may specify the default storage driver that should be used
| by the framework.
|
| Supported: "database", "filesystem", "Model"
|
*/

'driver' => 'model',

/*
|--------------------------------------------------------------------------
| Default Storage Driver
|--------------------------------------------------------------------------
|
| Here you may specify the default cache driver that should be used
| by the framework.
|
| Supported: all cache drivers supported by Laravel
|
*/

'cache_driver' => null,

/*
|--------------------------------------------------------------------------
| Storage Specific Configuration
|--------------------------------------------------------------------------
|
| Here you may configure as many storage drivers as you wish.
|
*/

'drivers' => [

'database' => [
'class' => \ForexAPI\Currency\Drivers\Database::class,
'connection' => null,
'table' => 'currencies',
],

'filesystem' => [
'class' => \ForexAPI\Currency\Drivers\Filesystem::class,
'disk' => null,
'path' => 'currencies.json',
],

'model' => [
'table' => 'currencies',
'class' => Currency::class
],

],

/*
|--------------------------------------------------------------------------
| Currency Formatter
|--------------------------------------------------------------------------
|
| Here you may configure a custom formatting of currencies. The reason for
| this is to help further internationalize the formatting past the basic
| format column in the table. When set to `null` the package will use the
| format from storage.
|
|
*/

'formatter' => null,

/*
|--------------------------------------------------------------------------
| Currency Formatter Specific Configuration
|--------------------------------------------------------------------------
|
| Here you may configure as many currency formatters as you wish.
|
*/

'formatters' => [

'php_intl' => [
'class' => \ForexAPI\Currency\Formatters\PHPIntl::class,
],

],
];
50 changes: 50 additions & 0 deletions database/migrations/2013_11_26_161501_create_currency_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

use Illuminate\Database\Migrations\Migration;

class CreateCurrencyTable extends Migration
{
/**
* Currencies table name
*
* @var string
*/
protected $table_name;

/**
* Create a new migration instance.
*/
public function __construct()
{
$this->table_name = config('currency.drivers.database.table');
}

/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create($this->table_name, function ($table) {
$table->increments('id')->unsigned();
$table->string('name');
$table->string('code', 10)->index();
$table->string('symbol', 25);
$table->string('format', 50);
$table->string('exchange_rate');
$table->boolean('active')->default(false);
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop($this->table_name);
}
}
26 changes: 26 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0"?>
<ruleset name="PSR2-package">
<description>The PSR2 standard</description>

<!-- use preg_match https://github.com/squizlabs/PHP_CodeSniffer/issues/742#issuecomment-215250517 -->
<exclude-pattern>/resources/</exclude-pattern>
<exclude-pattern>/vendor/</exclude-pattern>
<exclude-pattern>/_[a-zA-Z0-9\._]+\.php</exclude-pattern>
<exclude-pattern>/\.[a-zA-Z0-9\._]+\.php</exclude-pattern>
<exclude-pattern>\.git</exclude-pattern>

<!-- Include the whole PSR2 standard -->
<rule ref="PSR2">
<exclude name="PSR1.Methods.CamelCapsMethodName"/>
<exclude name="PSR2.Files.EndFileNewline"/>
<exclude name="PSR2.Methods.FunctionCallSignature.MultipleArguments"/>
<exclude name="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace"/>
</rule>

<!-- Lines can be longer -->
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="9999"/>
</properties>
</rule>
</ruleset>
10 changes: 10 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
parameters:
excludes_analyse:
- vendor
- resources
ignoreErrors:
- '#Function app not found#'
- '#Function config_path not found#'
- '#Function base_path not found#'
- '#Function config not found#'
- '#Parameter \$request of method#'
18 changes: 18 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
Loading

0 comments on commit 8fa77ec

Please sign in to comment.