Inital commit
This commit is contained in:
1
core/vendor/thelia/currency-converter/.gitignore
vendored
Normal file
1
core/vendor/thelia/currency-converter/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
vendor/
|
||||
18
core/vendor/thelia/currency-converter/.travis.yml
vendored
Normal file
18
core/vendor/thelia/currency-converter/.travis.yml
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- hhvm
|
||||
- nightly
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php: nightly
|
||||
|
||||
before_script:
|
||||
- composer self-update
|
||||
- composer install --dev
|
||||
|
||||
script: phpunit
|
||||
165
core/vendor/thelia/currency-converter/LICENSE.txt
vendored
Normal file
165
core/vendor/thelia/currency-converter/LICENSE.txt
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
67
core/vendor/thelia/currency-converter/Readme.md
vendored
Normal file
67
core/vendor/thelia/currency-converter/Readme.md
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
# Currency Converter
|
||||
|
||||
**Currency Converter** is a Library which helps you to convert a number from a currency to an another one.
|
||||
The converter uses *provider* for converting the number. Each provider embed the logic for converting this number.
|
||||
|
||||
[](https://travis-ci.org/thelia/CurrencyConverter) [](https://packagist.org/packages/thelia/currency-converter) [](https://scrutinizer-ci.com/g/thelia/CurrencyConverter/?branch=master)
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
**Currency Converter** is still in development and doesn't have stable version for now.
|
||||
|
||||
Install **Currency Converter** through [Composer](http://getcomposer.org)
|
||||
|
||||
Create a composer.json file in your project with this content :
|
||||
|
||||
```
|
||||
{
|
||||
"require": {
|
||||
"thelia/currency-converter": "~1.0"
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
First, instantiate a ```Provider``` of your choice
|
||||
|
||||
```
|
||||
$provider = new \Thelia\CurrencyConverter\Provider\ECBProvider();
|
||||
```
|
||||
|
||||
Then inject it in the ```CurrencyConverter```
|
||||
|
||||
```
|
||||
$currencyConverty = new \Thelia\CurrencyConverter\CurrencyConverter($provider);
|
||||
```
|
||||
|
||||
Your ```CurrencyConverter``` is now ready to be used.
|
||||
This library works with [ISO Code 4217](http://fr.wikipedia.org/wiki/ISO_4217) currency.
|
||||
|
||||
Example :
|
||||
|
||||
```
|
||||
$baseValue = new \Thelia\Math\Number('1');
|
||||
|
||||
$convertedValue = $currencyConverter
|
||||
->from('EUR')
|
||||
->to('USD')
|
||||
->convert($baseValue);
|
||||
|
||||
echo $baseValue->getNumber(); //1.24
|
||||
```
|
||||
|
||||
## Providers
|
||||
|
||||
A provider implements a simple interface and contains all the logic for converting a Number
|
||||
from a Currency to an other one. Most of time a provider will use a webservice for getting
|
||||
the exchange rate between two currencies.
|
||||
|
||||
List of available providers :
|
||||
|
||||
| Provider | Description |
|
||||
|---------:|-------------|
|
||||
| [European Central Bank](http://www.ecb.europa.eu/stats/exchange/eurofxref/html/index.en.html) | All currencies quoted against the euro (base currency) |
|
||||
|
||||
29
core/vendor/thelia/currency-converter/composer.json
vendored
Normal file
29
core/vendor/thelia/currency-converter/composer.json
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "thelia/currency-converter",
|
||||
"description": "php 5.4 currency tools",
|
||||
"license": "LGPL-3.0+",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Manuel Raynaud",
|
||||
"email": "manu@thelia.net"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"thelia/math-tools": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.3"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {"Thelia\\CurrencyConverter\\": "src/"}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {"Thelia\\CurrencyConverter\\Tests\\": "tests/"}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
806
core/vendor/thelia/currency-converter/composer.lock
generated
vendored
Normal file
806
core/vendor/thelia/currency-converter/composer.lock
generated
vendored
Normal file
@@ -0,0 +1,806 @@
|
||||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "94f5787ba4d31a54cbe7f90f27913aa1",
|
||||
"content-hash": "15b6750be8c220747c147b51b8603bf0",
|
||||
"packages": [
|
||||
{
|
||||
"name": "thelia/math-tools",
|
||||
"version": "1.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/thelia/math-tools.git",
|
||||
"reference": "4e66cd5448531a6eaf565acd8b69d9c693da7a3a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/thelia/math-tools/zipball/4e66cd5448531a6eaf565acd8b69d9c693da7a3a",
|
||||
"reference": "4e66cd5448531a6eaf565acd8b69d9c693da7a3a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.1.*"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Thelia\\Math\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"LGPL"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Benjamin Perche",
|
||||
"email": "bperche@openstudio.com"
|
||||
}
|
||||
],
|
||||
"description": "Number management library",
|
||||
"time": "2015-11-05 15:52:55"
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "doctrine/instantiator",
|
||||
"version": "1.0.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/instantiator.git",
|
||||
"reference": "f976e5de371104877ebc89bd8fecb0019ed9c119"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/f976e5de371104877ebc89bd8fecb0019ed9c119",
|
||||
"reference": "f976e5de371104877ebc89bd8fecb0019ed9c119",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3,<8.0-DEV"
|
||||
},
|
||||
"require-dev": {
|
||||
"athletic/athletic": "~0.1.8",
|
||||
"ext-pdo": "*",
|
||||
"ext-phar": "*",
|
||||
"phpunit/phpunit": "~4.0",
|
||||
"squizlabs/php_codesniffer": "2.0.*@ALPHA"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Doctrine\\Instantiator\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Marco Pivetta",
|
||||
"email": "ocramius@gmail.com",
|
||||
"homepage": "http://ocramius.github.com/"
|
||||
}
|
||||
],
|
||||
"description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
|
||||
"homepage": "https://github.com/doctrine/instantiator",
|
||||
"keywords": [
|
||||
"constructor",
|
||||
"instantiate"
|
||||
],
|
||||
"time": "2014-10-13 12:58:55"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
"version": "2.0.11",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
||||
"reference": "53603b3c995f5aab6b59c8e08c3a663d2cc810b7"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/53603b3c995f5aab6b59c8e08c3a663d2cc810b7",
|
||||
"reference": "53603b3c995f5aab6b59c8e08c3a663d2cc810b7",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"phpunit/php-file-iterator": "~1.3",
|
||||
"phpunit/php-text-template": "~1.2",
|
||||
"phpunit/php-token-stream": "~1.3",
|
||||
"sebastian/environment": "~1.0",
|
||||
"sebastian/version": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-xdebug": ">=2.1.4",
|
||||
"phpunit/phpunit": "~4.1"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-dom": "*",
|
||||
"ext-xdebug": ">=2.2.1",
|
||||
"ext-xmlwriter": "*"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"include-path": [
|
||||
""
|
||||
],
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sb@sebastian-bergmann.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.",
|
||||
"homepage": "https://github.com/sebastianbergmann/php-code-coverage",
|
||||
"keywords": [
|
||||
"coverage",
|
||||
"testing",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2014-08-31 06:33:04"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-file-iterator",
|
||||
"version": "1.3.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
|
||||
"reference": "acd690379117b042d1c8af1fafd61bde001bf6bb"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb",
|
||||
"reference": "acd690379117b042d1c8af1fafd61bde001bf6bb",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"File/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"include-path": [
|
||||
""
|
||||
],
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sb@sebastian-bergmann.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "FilterIterator implementation that filters files based on a list of suffixes.",
|
||||
"homepage": "https://github.com/sebastianbergmann/php-file-iterator/",
|
||||
"keywords": [
|
||||
"filesystem",
|
||||
"iterator"
|
||||
],
|
||||
"time": "2013-10-10 15:34:57"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-text-template",
|
||||
"version": "1.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-text-template.git",
|
||||
"reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a",
|
||||
"reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"Text/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"include-path": [
|
||||
""
|
||||
],
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sb@sebastian-bergmann.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "Simple template engine.",
|
||||
"homepage": "https://github.com/sebastianbergmann/php-text-template/",
|
||||
"keywords": [
|
||||
"template"
|
||||
],
|
||||
"time": "2014-01-30 17:20:04"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-timer",
|
||||
"version": "1.0.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-timer.git",
|
||||
"reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c",
|
||||
"reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"PHP/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"include-path": [
|
||||
""
|
||||
],
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sb@sebastian-bergmann.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "Utility class for timing",
|
||||
"homepage": "https://github.com/sebastianbergmann/php-timer/",
|
||||
"keywords": [
|
||||
"timer"
|
||||
],
|
||||
"time": "2013-08-02 07:42:54"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-token-stream",
|
||||
"version": "1.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
|
||||
"reference": "f8d5d08c56de5cfd592b3340424a81733259a876"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/f8d5d08c56de5cfd592b3340424a81733259a876",
|
||||
"reference": "f8d5d08c56de5cfd592b3340424a81733259a876",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-tokenizer": "*",
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.2"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de"
|
||||
}
|
||||
],
|
||||
"description": "Wrapper around PHP's tokenizer extension.",
|
||||
"homepage": "https://github.com/sebastianbergmann/php-token-stream/",
|
||||
"keywords": [
|
||||
"tokenizer"
|
||||
],
|
||||
"time": "2014-08-31 06:12:13"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "4.3.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "23e4e0310f037aae873cc81b8658dbbb82878f71"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/23e4e0310f037aae873cc81b8658dbbb82878f71",
|
||||
"reference": "23e4e0310f037aae873cc81b8658dbbb82878f71",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-dom": "*",
|
||||
"ext-json": "*",
|
||||
"ext-pcre": "*",
|
||||
"ext-reflection": "*",
|
||||
"ext-spl": "*",
|
||||
"php": ">=5.3.3",
|
||||
"phpunit/php-code-coverage": "~2.0",
|
||||
"phpunit/php-file-iterator": "~1.3.2",
|
||||
"phpunit/php-text-template": "~1.2",
|
||||
"phpunit/php-timer": "~1.0.2",
|
||||
"phpunit/phpunit-mock-objects": "~2.3",
|
||||
"sebastian/comparator": "~1.0",
|
||||
"sebastian/diff": "~1.1",
|
||||
"sebastian/environment": "~1.0",
|
||||
"sebastian/exporter": "~1.0",
|
||||
"sebastian/version": "~1.0",
|
||||
"symfony/yaml": "~2.0"
|
||||
},
|
||||
"suggest": {
|
||||
"phpunit/php-invoker": "~1.1"
|
||||
},
|
||||
"bin": [
|
||||
"phpunit"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.3.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"include-path": [
|
||||
"",
|
||||
"../../symfony/yaml/"
|
||||
],
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "The PHP Unit Testing framework.",
|
||||
"homepage": "http://www.phpunit.de/",
|
||||
"keywords": [
|
||||
"phpunit",
|
||||
"testing",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2014-10-22 11:43:12"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit-mock-objects",
|
||||
"version": "2.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
|
||||
"reference": "c63d2367247365f688544f0d500af90a11a44c65"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/c63d2367247365f688544f0d500af90a11a44c65",
|
||||
"reference": "c63d2367247365f688544f0d500af90a11a44c65",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"doctrine/instantiator": "~1.0,>=1.0.1",
|
||||
"php": ">=5.3.3",
|
||||
"phpunit/php-text-template": "~1.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.3"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-soap": "*"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.3.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sb@sebastian-bergmann.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "Mock Object library for PHPUnit",
|
||||
"homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/",
|
||||
"keywords": [
|
||||
"mock",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2014-10-03 05:12:11"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/comparator",
|
||||
"version": "1.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/comparator.git",
|
||||
"reference": "e54a01c0da1b87db3c5a3c4c5277ddf331da4aef"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/e54a01c0da1b87db3c5a3c4c5277ddf331da4aef",
|
||||
"reference": "e54a01c0da1b87db3c5a3c4c5277ddf331da4aef",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"sebastian/diff": "~1.1",
|
||||
"sebastian/exporter": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.1"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jeff Welch",
|
||||
"email": "whatthejeff@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Volker Dusch",
|
||||
"email": "github@wallbash.com"
|
||||
},
|
||||
{
|
||||
"name": "Bernhard Schussek",
|
||||
"email": "bschussek@2bepublished.at"
|
||||
},
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de"
|
||||
}
|
||||
],
|
||||
"description": "Provides the functionality to compare PHP values for equality",
|
||||
"homepage": "http://www.github.com/sebastianbergmann/comparator",
|
||||
"keywords": [
|
||||
"comparator",
|
||||
"compare",
|
||||
"equality"
|
||||
],
|
||||
"time": "2014-05-11 23:00:21"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/diff",
|
||||
"version": "1.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/diff.git",
|
||||
"reference": "5843509fed39dee4b356a306401e9dd1a931fec7"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/5843509fed39dee4b356a306401e9dd1a931fec7",
|
||||
"reference": "5843509fed39dee4b356a306401e9dd1a931fec7",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.2"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.2-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kore Nordmann",
|
||||
"email": "mail@kore-nordmann.de"
|
||||
},
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de"
|
||||
}
|
||||
],
|
||||
"description": "Diff implementation",
|
||||
"homepage": "http://www.github.com/sebastianbergmann/diff",
|
||||
"keywords": [
|
||||
"diff"
|
||||
],
|
||||
"time": "2014-08-15 10:29:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/environment",
|
||||
"version": "1.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/environment.git",
|
||||
"reference": "0d9bf79554d2a999da194a60416c15cf461eb67d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/0d9bf79554d2a999da194a60416c15cf461eb67d",
|
||||
"reference": "0d9bf79554d2a999da194a60416c15cf461eb67d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.3"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.2.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de"
|
||||
}
|
||||
],
|
||||
"description": "Provides functionality to handle HHVM/PHP environments",
|
||||
"homepage": "http://www.github.com/sebastianbergmann/environment",
|
||||
"keywords": [
|
||||
"Xdebug",
|
||||
"environment",
|
||||
"hhvm"
|
||||
],
|
||||
"time": "2014-10-22 06:38:05"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/exporter",
|
||||
"version": "1.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/exporter.git",
|
||||
"reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/c7d59948d6e82818e1bdff7cadb6c34710eb7dc0",
|
||||
"reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jeff Welch",
|
||||
"email": "whatthejeff@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Volker Dusch",
|
||||
"email": "github@wallbash.com"
|
||||
},
|
||||
{
|
||||
"name": "Bernhard Schussek",
|
||||
"email": "bschussek@2bepublished.at"
|
||||
},
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de"
|
||||
},
|
||||
{
|
||||
"name": "Adam Harvey",
|
||||
"email": "aharvey@php.net"
|
||||
}
|
||||
],
|
||||
"description": "Provides the functionality to export PHP variables for visualization",
|
||||
"homepage": "http://www.github.com/sebastianbergmann/exporter",
|
||||
"keywords": [
|
||||
"export",
|
||||
"exporter"
|
||||
],
|
||||
"time": "2014-09-10 00:51:36"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/version",
|
||||
"version": "1.0.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/version.git",
|
||||
"reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/version/zipball/b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43",
|
||||
"reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43",
|
||||
"shasum": ""
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
|
||||
"homepage": "https://github.com/sebastianbergmann/version",
|
||||
"time": "2014-03-07 15:35:33"
|
||||
},
|
||||
{
|
||||
"name": "symfony/yaml",
|
||||
"version": "v2.5.6",
|
||||
"target-dir": "Symfony/Component/Yaml",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Yaml.git",
|
||||
"reference": "2d9f527449cabfa8543dd7fa3a466d6ae83d6726"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Yaml/zipball/2d9f527449cabfa8543dd7fa3a466d6ae83d6726",
|
||||
"reference": "2d9f527449cabfa8543dd7fa3a466d6ae83d6726",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.5-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Symfony\\Component\\Yaml\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://symfony.com/contributors"
|
||||
},
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Yaml Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2014-10-01 05:50:18"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": {
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"platform-dev": []
|
||||
}
|
||||
17
core/vendor/thelia/currency-converter/phpunit.xml.dist
vendored
Normal file
17
core/vendor/thelia/currency-converter/phpunit.xml.dist
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit bootstrap="./tests/bootstrap.php"
|
||||
colors="true">
|
||||
<testsuites>
|
||||
<testsuite>
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">src</directory>
|
||||
<exclude>
|
||||
<directory suffix="Interface.php">src/</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
137
core/vendor/thelia/currency-converter/src/CurrencyConverter.php
vendored
Normal file
137
core/vendor/thelia/currency-converter/src/CurrencyConverter.php
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\CurrencyConverter;
|
||||
|
||||
use Thelia\CurrencyConverter\Exception\MissingProviderException;
|
||||
use Thelia\CurrencyConverter\Provider\ProviderInterface;
|
||||
use Thelia\Math\Number;
|
||||
|
||||
/**
|
||||
* Class Currency
|
||||
* @package Thelia\CurrencyConverter
|
||||
* @author Manuel Raynaud <manu@thelia.net>
|
||||
*/
|
||||
class CurrencyConverter
|
||||
{
|
||||
/**
|
||||
* @var ProviderInterface
|
||||
*/
|
||||
protected $provider;
|
||||
|
||||
/**
|
||||
* @var string Currency ISO Code 4217
|
||||
*/
|
||||
protected $from;
|
||||
|
||||
/**
|
||||
* @var string Currency ISO Code 4217
|
||||
*/
|
||||
protected $to;
|
||||
|
||||
/**
|
||||
* @param ProviderInterface $provider optional parameter
|
||||
*/
|
||||
public function __construct(ProviderInterface $provider = null)
|
||||
{
|
||||
$this->provider = $provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ProviderInterface $provider
|
||||
* @return self
|
||||
*/
|
||||
public function setProvider(ProviderInterface $provider)
|
||||
{
|
||||
$this->provider = $provider;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The origin currency
|
||||
*
|
||||
* @param string $value ISO Code 4217 (example : USD, EUR). See http://fr.wikipedia.org/wiki/ISO_4217
|
||||
* @return self
|
||||
*/
|
||||
public function from($value)
|
||||
{
|
||||
$this->from = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* the currency desired
|
||||
*
|
||||
* @param string $value ISO Code 4217 (example : USD, EUR). See http://fr.wikipedia.org/wiki/ISO_4217
|
||||
* @return self
|
||||
*/
|
||||
public function to($value)
|
||||
{
|
||||
$this->to = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* convert a currency from one to another one
|
||||
*
|
||||
* eg : $converter->from('EUR')->to('USD')->convert(Number('1'));
|
||||
*
|
||||
* @param \Thelia\Math\Number $number
|
||||
* @return \Thelia\Math\Number
|
||||
*/
|
||||
public function convert(Number $number)
|
||||
{
|
||||
$this->validate();
|
||||
$this->provider->from($this->from);
|
||||
$this->provider->to($this->to);
|
||||
$result = $this->provider->convert($number);
|
||||
|
||||
if (!($result instanceof \Thelia\Math\Number)) {
|
||||
throw new \LogicException('your provider must return a Thelia\Math\Number instance');
|
||||
}
|
||||
|
||||
$this->reset();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if the conversation can be done.
|
||||
*
|
||||
* @throws MissingProviderException thrown if the provider is missing
|
||||
* @throws \RuntimeException thrown if to or from parameters are missing
|
||||
*/
|
||||
private function validate()
|
||||
{
|
||||
if (null === $this->provider) {
|
||||
throw new MissingProviderException('A provider must be set for converting a currency');
|
||||
}
|
||||
|
||||
if (null === $this->from || null === $this->to) {
|
||||
throw new \RuntimeException('from and to parameters must be provided');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* remove from and to configuration.
|
||||
*/
|
||||
private function reset()
|
||||
{
|
||||
$this->from = null;
|
||||
$this->to = null;
|
||||
}
|
||||
}
|
||||
39
core/vendor/thelia/currency-converter/src/Exception/CurrencyNotFoundException.php
vendored
Normal file
39
core/vendor/thelia/currency-converter/src/Exception/CurrencyNotFoundException.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\CurrencyConverter\Exception;
|
||||
|
||||
/**
|
||||
* Class CurrencyNotFoundException
|
||||
* @author Manuel Raynaud <manu@thelia.net>
|
||||
*/
|
||||
class CurrencyNotFoundException extends \RuntimeException
|
||||
{
|
||||
protected $currency;
|
||||
|
||||
/**
|
||||
* @param string $currency
|
||||
*/
|
||||
public function __construct($currency, $message = null, $code = 0, \Exception $previous = null)
|
||||
{
|
||||
$this->currency = $currency;
|
||||
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string return the currency unknown
|
||||
*/
|
||||
public function getCurrency()
|
||||
{
|
||||
return $this->currency;
|
||||
}
|
||||
}
|
||||
27
core/vendor/thelia/currency-converter/src/Exception/MissingProviderException.php
vendored
Normal file
27
core/vendor/thelia/currency-converter/src/Exception/MissingProviderException.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\CurrencyConverter\Exception;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* exception thrown if the provider is missing
|
||||
*
|
||||
* Class MissingProviderException
|
||||
* @package Thelia\CurrencyConverter\Exception
|
||||
* @author Manuel Raynaud <manu@thelia.net>
|
||||
*/
|
||||
class MissingProviderException extends \RuntimeException
|
||||
{
|
||||
|
||||
}
|
||||
53
core/vendor/thelia/currency-converter/src/Provider/BaseProvider.php
vendored
Normal file
53
core/vendor/thelia/currency-converter/src/Provider/BaseProvider.php
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\CurrencyConverter\Provider;
|
||||
|
||||
/**
|
||||
* Class BaseProvider
|
||||
* @package Thelia\CurrencyConverter\Provider
|
||||
* @author Manuel Raynaud <manu@thelia.net>
|
||||
*/
|
||||
abstract class BaseProvider implements ProviderInterface
|
||||
{
|
||||
protected $from;
|
||||
|
||||
protected $to;
|
||||
|
||||
/**
|
||||
*
|
||||
* The origin currency
|
||||
*
|
||||
* @param string $value ISO Code 4217 (example : USD, EUR). See http://fr.wikipedia.org/wiki/ISO_4217
|
||||
* @return self
|
||||
*/
|
||||
public function from($value)
|
||||
{
|
||||
$this->from = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* the currency desired
|
||||
*
|
||||
* @param string $value ISO Code 4217 (example : USD, EUR). See http://fr.wikipedia.org/wiki/ISO_4217
|
||||
* @return self
|
||||
*/
|
||||
public function to($value)
|
||||
{
|
||||
$this->to = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
138
core/vendor/thelia/currency-converter/src/Provider/ECBProvider.php
vendored
Normal file
138
core/vendor/thelia/currency-converter/src/Provider/ECBProvider.php
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\CurrencyConverter\Provider;
|
||||
|
||||
use Thelia\CurrencyConverter\Exception\CurrencyNotFoundException;
|
||||
use Thelia\Math\Number;
|
||||
|
||||
/**
|
||||
*
|
||||
* Europen Central Bank provider.
|
||||
*
|
||||
* The European Central Bank provide all currencies quoted against the euro
|
||||
* The euro is the base currency
|
||||
*
|
||||
* Class ECBProvider
|
||||
* @package Thelia\CurrencyConverter\Provider
|
||||
* @author Manuel Raynaud <manu@thelia.net>
|
||||
*/
|
||||
class ECBProvider extends BaseProvider implements ProviderInterface
|
||||
{
|
||||
protected $endPoint = "http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml";
|
||||
|
||||
protected $data;
|
||||
|
||||
public function __construct($loadWebService = true)
|
||||
{
|
||||
if (true === $loadWebService) {
|
||||
$this->loadFromWebService();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function loadFromWebService($endPoint = null)
|
||||
{
|
||||
if (null !== $endPoint) {
|
||||
$this->endPoint = $endPoint;
|
||||
}
|
||||
|
||||
$ch = curl_init($this->endPoint);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
|
||||
$data = curl_exec($ch);
|
||||
|
||||
$xml = new \SimpleXMLElement($data);
|
||||
|
||||
$this->data = $xml->Cube[0]->Cube[0];
|
||||
}
|
||||
|
||||
public function loadFromXml($data)
|
||||
{
|
||||
$xml = new \SimpleXMLElement($data);
|
||||
|
||||
$this->data = $xml->Cube[0]->Cube[0];
|
||||
}
|
||||
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function convert(Number $number)
|
||||
{
|
||||
$rateFactor = $this->retrieveRateFactor();
|
||||
|
||||
if ($this->to === 'EUR') {
|
||||
return $number->multiply($rateFactor);
|
||||
} else {
|
||||
return $this->convertToOther($rateFactor, $number);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Math\Number $rateFactor
|
||||
* @param \Thelia\Math\Number $number
|
||||
* @return \Thelia\Math\Number
|
||||
* @throws \Thelia\CurrencyConverter\Exception\CurrencyNotFoundException if the `to` currency is not support
|
||||
*/
|
||||
private function convertToOther(Number $rateFactor, Number $number)
|
||||
{
|
||||
$conversion = false;
|
||||
foreach ($this->data->Cube as $last) {
|
||||
$code = strtoupper($last["currency"]);
|
||||
|
||||
if ($code === $this->to) {
|
||||
$rate = $rateFactor->multiply((string) $last['rate']);
|
||||
$conversion = $number->multiply($rate);
|
||||
}
|
||||
}
|
||||
|
||||
if ($conversion === false) {
|
||||
throw new CurrencyNotFoundException($this->to);
|
||||
}
|
||||
|
||||
return $conversion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Thelia\Math\Number
|
||||
* @throws \Thelia\CurrencyConverter\Exception\CurrencyNotFoundException if the `from` currency is not support
|
||||
*/
|
||||
private function retrieveRateFactor()
|
||||
{
|
||||
$rateFactor = false;
|
||||
|
||||
if ($this->from === 'EUR') {
|
||||
$rateFactor = new Number(1);
|
||||
} else {
|
||||
// Find the exchange rate for this currency
|
||||
foreach ($this->data->Cube as $last) {
|
||||
$code = strtoupper((string) $last["currency"]);
|
||||
|
||||
if ($code === $this->from) {
|
||||
// Get the rate factor
|
||||
$rate = new Number((string) $last['rate']);
|
||||
$base = new Number(1);
|
||||
$rateFactor = $base->divide($rate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (false === $rateFactor) {
|
||||
throw new CurrencyNotFoundException($this->from);
|
||||
}
|
||||
|
||||
return $rateFactor;
|
||||
}
|
||||
}
|
||||
49
core/vendor/thelia/currency-converter/src/Provider/ProviderInterface.php
vendored
Normal file
49
core/vendor/thelia/currency-converter/src/Provider/ProviderInterface.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\CurrencyConverter\Provider;
|
||||
|
||||
use Thelia\Math\Number;
|
||||
|
||||
/**
|
||||
* Interface ProviderInterface
|
||||
* @package Thelia\CurrencyConverter\Provider
|
||||
* @author Manuel Raynaud <manu@thelia.net>
|
||||
*/
|
||||
interface ProviderInterface
|
||||
{
|
||||
/**
|
||||
*
|
||||
* The origin currency
|
||||
*
|
||||
* @param string $value ISO Code 4217 (example : USD, EUR). See http://fr.wikipedia.org/wiki/ISO_4217
|
||||
* @return self
|
||||
*/
|
||||
public function from($value);
|
||||
|
||||
/**
|
||||
*
|
||||
* the currency desired
|
||||
*
|
||||
* @param string $value ISO Code 4217 (example : USD, EUR). See http://fr.wikipedia.org/wiki/ISO_4217
|
||||
* @return self
|
||||
*/
|
||||
public function to($value);
|
||||
|
||||
/**
|
||||
* return the conversion
|
||||
*
|
||||
* @param \Thelia\Math\Number $number
|
||||
* @return mixed
|
||||
*/
|
||||
public function convert(Number $number);
|
||||
}
|
||||
144
core/vendor/thelia/currency-converter/tests/CurrencyConverterTest.php
vendored
Normal file
144
core/vendor/thelia/currency-converter/tests/CurrencyConverterTest.php
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\CurrencyConverter\Tests;
|
||||
|
||||
use Thelia\CurrencyConverter\CurrencyConverter;
|
||||
use Thelia\Math\Number;
|
||||
|
||||
class CurrencyConverterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \Thelia\CurrencyConverter\CurrencyConverter::convert
|
||||
* @covers \Thelia\CurrencyConverter\CurrencyConverter::__construct
|
||||
* @covers \Thelia\CurrencyConverter\CurrencyConverter::validate
|
||||
* @covers \Thelia\CurrencyConverter\CurrencyConverter::to
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testConvertWithoutFrom()
|
||||
{
|
||||
$currencyConverter = new CurrencyConverter($this->getProvider());
|
||||
$currencyConverter->to('EUR');
|
||||
$currencyConverter->convert(new Number(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Thelia\CurrencyConverter\CurrencyConverter::convert
|
||||
* @covers \Thelia\CurrencyConverter\CurrencyConverter::validate
|
||||
* @covers \Thelia\CurrencyConverter\CurrencyConverter::from
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testConvertWithoutTo()
|
||||
{
|
||||
$currencyConverter = new CurrencyConverter($this->getProvider());
|
||||
$currencyConverter->from('EUR');
|
||||
$currencyConverter->convert(new Number(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Thelia\CurrencyConverter\CurrencyConverter::convert
|
||||
* @covers \Thelia\CurrencyConverter\CurrencyConverter::validate
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testConvertWithoutToAndFrom()
|
||||
{
|
||||
$currencyConverter = new CurrencyConverter($this->getProvider());
|
||||
$currencyConverter->convert(new Number(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Thelia\CurrencyConverter\CurrencyConverter::convert
|
||||
* @expectedException \LogicException
|
||||
*/
|
||||
public function testConvertWithBadProvider()
|
||||
{
|
||||
$currencyConverter = new CurrencyConverter($this->getMock('\Thelia\CurrencyConverter\Provider\ProviderInterface'));
|
||||
$currencyConverter->from('EUR');
|
||||
$currencyConverter->to('USD');
|
||||
$currencyConverter->convert(new Number(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Thelia\CurrencyConverter\CurrencyConverter::convert
|
||||
* @covers \Thelia\CurrencyConverter\CurrencyConverter::validate
|
||||
* @expectedException \Thelia\CurrencyConverter\Exception\MissingProviderException
|
||||
*/
|
||||
public function testConvertWithoutProvider()
|
||||
{
|
||||
$currencyConverter = new CurrencyConverter();
|
||||
$currencyConverter
|
||||
->from('USD')
|
||||
->to('EUR')
|
||||
->convert(new Number('1'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Thelia\CurrencyConverter\CurrencyConverter::convert
|
||||
* @covers \Thelia\CurrencyConverter\CurrencyConverter::reset
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testConvertTwice()
|
||||
{
|
||||
$number = new Number(1);
|
||||
|
||||
$currencyConverter = new CurrencyConverter($this->getProvider());
|
||||
$currencyConverter->from('EUR');
|
||||
$currencyConverter->to('USD');
|
||||
$currencyConverter->convert($number);
|
||||
|
||||
$currencyConverter->convert($number);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Thelia\CurrencyConverter\CurrencyConverter::convert
|
||||
* @covers \Thelia\CurrencyConverter\CurrencyConverter::__construct
|
||||
*/
|
||||
public function testConvertWithSetterProvider()
|
||||
{
|
||||
$currencyConverter = new CurrencyConverter($this->getProvider());
|
||||
|
||||
$result = $currencyConverter
|
||||
->from('EUR')
|
||||
->to('USD')
|
||||
->convert(new Number('1'));
|
||||
|
||||
$this->assertInstanceOf('Thelia\Math\Number', $result, 'the converter must return an instance of \Thelia\Math\Number');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Thelia\CurrencyConverter\CurrencyConverter::convert
|
||||
* @covers \Thelia\CurrencyConverter\CurrencyConverter::validate
|
||||
* @covers \Thelia\CurrencyConverter\CurrencyConverter::setProvider
|
||||
*/
|
||||
public function testConvert()
|
||||
{
|
||||
$currencyConverter = new CurrencyConverter();
|
||||
|
||||
$result = $currencyConverter
|
||||
->setProvider($this->getProvider())
|
||||
->from('EUR')
|
||||
->to('USD')
|
||||
->convert(new Number('1'));
|
||||
|
||||
$this->assertInstanceOf('Thelia\Math\Number', $result, 'the converter must return an instance of \Thelia\Math\Number');
|
||||
}
|
||||
|
||||
public function getProvider()
|
||||
{
|
||||
$provider = $this->getMock('\Thelia\CurrencyConverter\Provider\ProviderInterface');
|
||||
|
||||
$provider->method('convert')
|
||||
->willReturn(new Number(1));
|
||||
|
||||
return $provider;
|
||||
}
|
||||
}
|
||||
192
core/vendor/thelia/currency-converter/tests/Provider/ECBProviderTest.php
vendored
Normal file
192
core/vendor/thelia/currency-converter/tests/Provider/ECBProviderTest.php
vendored
Normal file
@@ -0,0 +1,192 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\CurrencyConverter\Tests\Provider;
|
||||
|
||||
use Thelia\CurrencyConverter\Exception\CurrencyNotFoundException;
|
||||
use Thelia\CurrencyConverter\Provider\ECBProvider;
|
||||
use Thelia\Math\Number;
|
||||
|
||||
class ECBProviderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public $data = <<<XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gesmes:Envelope
|
||||
xmlns:gesmes="http://www.gesmes.org/xml/2002-08-01"
|
||||
xmlns="http://www.ecb.int/vocabulary/2002-08-01/eurofxref">
|
||||
<gesmes:subject>Reference rates</gesmes:subject>
|
||||
<gesmes:Sender>
|
||||
<gesmes:name>European Central Bank</gesmes:name>
|
||||
</gesmes:Sender>
|
||||
<Cube>
|
||||
<Cube time='2014-11-07'>
|
||||
<Cube currency='USD' rate='1.2393'/>
|
||||
<Cube currency='GBP' rate='0.78340'/>
|
||||
</Cube>
|
||||
</Cube>
|
||||
</gesmes:Envelope>
|
||||
XML;
|
||||
|
||||
/**
|
||||
* @var \Thelia\CurrencyConverter\Provider\ECBProvider
|
||||
*/
|
||||
public $provider;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->provider = new ECBProvider(false);
|
||||
|
||||
$this->provider->loadFromXml($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Thelia\CurrencyConverter\Provider\ECBProvider::convert
|
||||
* @covers \Thelia\CurrencyConverter\Provider\ECBProvider::retrieveRateFactor
|
||||
*/
|
||||
public function testFromEuro()
|
||||
{
|
||||
$provider = $this->provider;
|
||||
$number = new Number(1);
|
||||
|
||||
$usdRate = $provider->from('EUR')->to('USD')->convert($number);
|
||||
|
||||
$this->assertInstanceOf('Thelia\Math\Number', $usdRate, "the provider must return an instance of Number");
|
||||
$this->assertEquals('1.2393', $usdRate->getNumber(-1), "the expected result from EUR to USD is 1.2393");
|
||||
|
||||
$gbpRate = $provider->from('EUR')->to('GBP')->convert($number);
|
||||
|
||||
$this->assertInstanceOf('Thelia\Math\Number', $gbpRate, "the provider must return an instance of Number");
|
||||
$this->assertEquals('0.78340', $gbpRate->getNumber(-1), "the expected result from EUR to GBP is 0.78340");
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Thelia\CurrencyConverter\Provider\ECBProvider::convert
|
||||
* @covers \Thelia\CurrencyConverter\Provider\ECBProvider::retrieveRateFactor
|
||||
* @covers \Thelia\CurrencyConverter\Provider\ECBProvider::convertToOther
|
||||
*/
|
||||
public function testFromUsd()
|
||||
{
|
||||
$provider = $this->provider;
|
||||
$number = new Number(1);
|
||||
|
||||
$euroRate = $provider->from('USD')->to('EUR')->convert($number);
|
||||
|
||||
$this->assertInstanceOf('Thelia\Math\Number', $euroRate, "the provider must return an instance of Number");
|
||||
$this->assertEquals('0.80690712498991', $euroRate->getNumber(-1), "the expected result from USD to EUR is 0.80690712498991");
|
||||
|
||||
$gbpRate = $provider->from('USD')->to('GBP')->convert($number);
|
||||
|
||||
$this->assertInstanceOf('Thelia\Math\Number', $gbpRate, "the provider must return an instance of Number");
|
||||
$this->assertEquals('0.6321310417171', $gbpRate->getNumber(-1), "the expected result from USD to GBP is 0.6321310417171");
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Thelia\CurrencyConverter\Provider\ECBProvider::convert
|
||||
* @covers \Thelia\CurrencyConverter\Provider\ECBProvider::retrieveRateFactor
|
||||
* @covers \Thelia\CurrencyConverter\Provider\ECBProvider::convertToOther
|
||||
*/
|
||||
public function testFromGbp()
|
||||
{
|
||||
$provider = $this->provider;
|
||||
$number = new Number(1);
|
||||
|
||||
$euroRate = $provider->from('GBP')->to('EUR')->convert($number);
|
||||
|
||||
$this->assertInstanceOf('Thelia\Math\Number', $euroRate, "the provider must return an instance of Number");
|
||||
$this->assertEquals('1.2764871074802', $euroRate->getNumber(-1), "the expected result from GBP to EUR is 1.2764871074802");
|
||||
|
||||
$usdRate = $provider->from('GBP')->to('USD')->convert($number);
|
||||
|
||||
$this->assertInstanceOf('Thelia\Math\Number', $usdRate, "the provider must return an instance of Number");
|
||||
$this->assertEquals('1.5819504723002', $usdRate->getNumber(-1), "the expected result from GBP to USD is 1.5819504723002");
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Thelia\CurrencyConverter\Exception\CurrencyNotFoundException
|
||||
* @covers \Thelia\CurrencyConverter\Provider\ECBProvider::retrieveRateFactor
|
||||
*/
|
||||
public function testResolveWithUnknownCurrencies()
|
||||
{
|
||||
$provider = $this->provider;
|
||||
$number = new Number(1);
|
||||
|
||||
$rate = $provider->from('FOO')->to('BAR')->convert($number);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Thelia\CurrencyConverter\Exception\CurrencyNotFoundException
|
||||
* @covers \Thelia\CurrencyConverter\Provider\ECBProvider::retrieveRateFactor
|
||||
*/
|
||||
public function testConvertWithUnknowFrom()
|
||||
{
|
||||
$provider = $this->provider;
|
||||
$number = new Number(1);
|
||||
|
||||
$rate = $provider->from('FOO')->to('USD')->convert($number);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Thelia\CurrencyConverter\Exception\CurrencyNotFoundException
|
||||
* @covers \Thelia\CurrencyConverter\Provider\ECBProvider::retrieveRateFactor
|
||||
* @covers \Thelia\CurrencyConverter\Provider\ECBProvider::convertToOther
|
||||
*/
|
||||
public function testConvertWithUnknownTo()
|
||||
{
|
||||
$provider = $this->provider;
|
||||
$number = new Number(1);
|
||||
|
||||
$rate = $provider->from('EUR')->to('FOO')->convert($number);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Thelia\CurrencyConverter\Provider\ECBProvider::loadFromWebservice
|
||||
* @covers \Thelia\CurrencyConverter\Provider\ECBProvider::getData
|
||||
* @covers \Thelia\CurrencyConverter\Provider\ECBProvider::__construct
|
||||
*/
|
||||
public function testLoadFromWerbservice()
|
||||
{
|
||||
$provider = new ECBProvider();
|
||||
|
||||
$data = $provider->getData();
|
||||
|
||||
$this->assertInstanceOf('\SimpleXmlElement', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Thelia\CurrencyConverter\Provider\ECBProvider::loadFromXml
|
||||
* @covers \Thelia\CurrencyConverter\Provider\ECBProvider::getData
|
||||
*/
|
||||
public function testLoadFromXml()
|
||||
{
|
||||
$provider = new ECBProvider(false);
|
||||
$provider->loadFromXml($this->data);
|
||||
|
||||
$data = $provider->getData();
|
||||
|
||||
$this->assertInstanceOf('\SimpleXmlElement', $data);
|
||||
}
|
||||
|
||||
public function testConvertWithException()
|
||||
{
|
||||
try {
|
||||
$provider = $this->provider;
|
||||
$number = new Number(1);
|
||||
|
||||
$rate = $provider->from('FOO')->to('USD')->convert($number);
|
||||
} catch (CurrencyNotFoundException $e) {
|
||||
$this->assertEquals('FOO', $e->getCurrency());
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail('try converting with unknown currencies must fail');
|
||||
}
|
||||
}
|
||||
13
core/vendor/thelia/currency-converter/tests/bootstrap.php
vendored
Normal file
13
core/vendor/thelia/currency-converter/tests/bootstrap.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
3
core/vendor/thelia/installer/.gitignore
vendored
Normal file
3
core/vendor/thelia/installer/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
composer.lock
|
||||
vendor
|
||||
.idea
|
||||
45
core/vendor/thelia/installer/Readme.md
vendored
Normal file
45
core/vendor/thelia/installer/Readme.md
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
# Custom installer for [Composer](http://getcomposer.org)
|
||||
|
||||
This installer allows you to install module and templates using composer. We created special ```type``` for Thelia
|
||||
|
||||
You can now create module and submit them on [packagist.org](http://packagist.org)
|
||||
|
||||
List of special types :
|
||||
|
||||
- ```thelia-module``` => install your module in ```local/module```
|
||||
- ```thelia-frontoffice-template``` => install your template in ```templates/frontOffice```
|
||||
- ```thelia-backoffice-template``` => install your template in ```templates/backOffice```
|
||||
- ```thelia-email-template``` => install your template in ```templates/email```
|
||||
- ```thelia-pdf-template``` => install your template in ```templates/pdf```
|
||||
|
||||
## Example ```composer.json``` file
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "thelia/hooktest-module",
|
||||
"type": "thelia-module",
|
||||
"require": {
|
||||
"thelia/installer": "~1.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This would install your module in ```local/modules/hookstest-module```
|
||||
|
||||
You certainly notice that ```hooktest-module``` is not a valid name for a Thelia module. In fact [packagist.org](http://packagist.org) doesn't allow
|
||||
package in uppercase. For fixing this, you must use an extra param in your composer.json
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "thelia/hooktest-module",
|
||||
"type": "thelia-module",
|
||||
"require": {
|
||||
"thelia/installer": "~1.0"
|
||||
},
|
||||
"extra": {
|
||||
"installer-name": "HookTest"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
With this new section, your module will be install now in ```local/modules/HookTest```
|
||||
30
core/vendor/thelia/installer/composer.json
vendored
Normal file
30
core/vendor/thelia/installer/composer.json
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "thelia/installer",
|
||||
"type": "composer-plugin",
|
||||
"license": "LGPL V3",
|
||||
"description": "custom installer for Thelia.",
|
||||
"keywords" : [
|
||||
"Thelia",
|
||||
"Thelia-module",
|
||||
"Thelia-template"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Manuel Raynaud",
|
||||
"email": "raynaud.manu@gmail.com",
|
||||
"homepage": "https://github.com/lunika"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-0": {"Thelia\\Composer": "src/"}
|
||||
},
|
||||
"extra": {
|
||||
"class": "Thelia\\Composer\\TheliaInstallerPlugin"
|
||||
},
|
||||
"require": {
|
||||
"composer-plugin-api": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"composer/composer": "1.0.*@dev"
|
||||
}
|
||||
}
|
||||
66
core/vendor/thelia/installer/src/Thelia/Composer/TheliaInstaller.php
vendored
Normal file
66
core/vendor/thelia/installer/src/Thelia/Composer/TheliaInstaller.php
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Composer;
|
||||
|
||||
use Composer\Installer\LibraryInstaller;
|
||||
use Composer\Package\PackageInterface;
|
||||
|
||||
/**
|
||||
* Class TheliaInstaller
|
||||
* @package Thelia\Composer
|
||||
* @author manuel raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class TheliaInstaller extends LibraryInstaller
|
||||
{
|
||||
protected $locations = [
|
||||
'thelia-module' => 'local/modules/',
|
||||
'thelia-frontoffice-template' => 'templates/frontOffice/',
|
||||
'thelia-backoffice-template' => 'templates/backOffice/',
|
||||
'thelia-email-template' => 'templates/email/',
|
||||
'thelia-pdf-template' => 'templates/pdf/',
|
||||
'thelia-local' => 'local/',
|
||||
];
|
||||
|
||||
public function getInstallPath(PackageInterface $package)
|
||||
{
|
||||
$type = $package->getType();
|
||||
if (!isset($this->locations[$package->getType()])) {
|
||||
throw new \InvalidArgumentException(sprintf('package type "%s" is not supported', $type));
|
||||
}
|
||||
|
||||
$base = $this->locations[$type];
|
||||
|
||||
$prettyName = $package->getPrettyName();
|
||||
if (strpos($prettyName, '/') !== false) {
|
||||
list($vendor, $name) = explode('/', $prettyName);
|
||||
} else {
|
||||
$vendor = '';
|
||||
$name = $prettyName;
|
||||
}
|
||||
|
||||
$extra = $package->getExtra();
|
||||
if (!empty($extra['installer-name'])) {
|
||||
$name = $extra['installer-name'];
|
||||
}
|
||||
|
||||
return $base . $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function supports($packageType)
|
||||
{
|
||||
return array_key_exists($packageType, $this->locations);
|
||||
}
|
||||
}
|
||||
30
core/vendor/thelia/installer/src/Thelia/Composer/TheliaInstallerPlugin.php
vendored
Normal file
30
core/vendor/thelia/installer/src/Thelia/Composer/TheliaInstallerPlugin.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Composer;
|
||||
|
||||
use Composer\Composer;
|
||||
use Composer\IO\IOInterface;
|
||||
use Composer\Plugin\PluginInterface;
|
||||
/**
|
||||
* Class InstallerPlugin
|
||||
* @package Thelia\Composer
|
||||
* @author manuel raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class TheliaInstallerPlugin implements PluginInterface
|
||||
{
|
||||
public function activate(Composer $composer, IOInterface $io)
|
||||
{
|
||||
$installer = new TheliaInstaller($io, $composer);
|
||||
$composer->getInstallationManager()->addInstaller($installer);
|
||||
}
|
||||
}
|
||||
2
core/vendor/thelia/math-tools/.gitignore
vendored
Normal file
2
core/vendor/thelia/math-tools/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/.idea
|
||||
/vendor/
|
||||
18
core/vendor/thelia/math-tools/.travis.yml
vendored
Normal file
18
core/vendor/thelia/math-tools/.travis.yml
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- hhvm
|
||||
- nightly
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php: nightly
|
||||
|
||||
before_script:
|
||||
- composer self-update
|
||||
- composer install --dev
|
||||
|
||||
script: phpunit
|
||||
166
core/vendor/thelia/math-tools/LICENSE
vendored
Normal file
166
core/vendor/thelia/math-tools/LICENSE
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
|
||||
32
core/vendor/thelia/math-tools/README.md
vendored
Normal file
32
core/vendor/thelia/math-tools/README.md
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
Maths tools
|
||||
===
|
||||
|
||||
This library includes some tools for math operations.
|
||||
|
||||
[](https://travis-ci.org/thelia/math-tools) [](https://packagist.org/packages/thelia/math-tools) [](https://scrutinizer-ci.com/g/thelia/math-tools/)
|
||||
|
||||
Number
|
||||
---
|
||||
|
||||
Here's an example of rounding problems solved by this lib:
|
||||
```php
|
||||
$price = new Number('3.99');
|
||||
|
||||
$price->divide('1.2');
|
||||
echo $price->getNumber(); // 3.33
|
||||
|
||||
$price->multiply('1.2');
|
||||
echo $price->getNumber(); // 3.99, where most of time libs returns 4.00
|
||||
```
|
||||
|
||||
GCD
|
||||
---
|
||||
|
||||
This tool computes the GCD of two numbers.
|
||||
|
||||
```php
|
||||
echo GCD::getGCD(10,5); // 5
|
||||
echo GCD::getGCD(10,10); // 10
|
||||
echo GCD::getGCD(20,10); // 10
|
||||
echo GCD::getGCD(11,10); // 1
|
||||
```
|
||||
25
core/vendor/thelia/math-tools/composer.json
vendored
Normal file
25
core/vendor/thelia/math-tools/composer.json
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "thelia/math-tools",
|
||||
"description": "Number management library",
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.1.*"
|
||||
},
|
||||
"license": "LGPL",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Benjamin Perche",
|
||||
"email": "bperche@openstudio.com"
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0-dev"
|
||||
}
|
||||
},
|
||||
"require": {},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Thelia\\Math\\":"src/"
|
||||
}
|
||||
}
|
||||
}
|
||||
708
core/vendor/thelia/math-tools/composer.lock
generated
vendored
Normal file
708
core/vendor/thelia/math-tools/composer.lock
generated
vendored
Normal file
@@ -0,0 +1,708 @@
|
||||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "5402140de486c0c5236eba84a3589bff",
|
||||
"packages": [],
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
"version": "2.0.11",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
||||
"reference": "53603b3c995f5aab6b59c8e08c3a663d2cc810b7"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/53603b3c995f5aab6b59c8e08c3a663d2cc810b7",
|
||||
"reference": "53603b3c995f5aab6b59c8e08c3a663d2cc810b7",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"phpunit/php-file-iterator": "~1.3",
|
||||
"phpunit/php-text-template": "~1.2",
|
||||
"phpunit/php-token-stream": "~1.3",
|
||||
"sebastian/environment": "~1.0",
|
||||
"sebastian/version": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-xdebug": ">=2.1.4",
|
||||
"phpunit/phpunit": "~4.1"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-dom": "*",
|
||||
"ext-xdebug": ">=2.2.1",
|
||||
"ext-xmlwriter": "*"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"include-path": [
|
||||
""
|
||||
],
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sb@sebastian-bergmann.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.",
|
||||
"homepage": "https://github.com/sebastianbergmann/php-code-coverage",
|
||||
"keywords": [
|
||||
"coverage",
|
||||
"testing",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2014-08-31 06:33:04"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-file-iterator",
|
||||
"version": "1.3.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
|
||||
"reference": "acd690379117b042d1c8af1fafd61bde001bf6bb"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb",
|
||||
"reference": "acd690379117b042d1c8af1fafd61bde001bf6bb",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"File/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"include-path": [
|
||||
""
|
||||
],
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sb@sebastian-bergmann.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "FilterIterator implementation that filters files based on a list of suffixes.",
|
||||
"homepage": "https://github.com/sebastianbergmann/php-file-iterator/",
|
||||
"keywords": [
|
||||
"filesystem",
|
||||
"iterator"
|
||||
],
|
||||
"time": "2013-10-10 15:34:57"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-text-template",
|
||||
"version": "1.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-text-template.git",
|
||||
"reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a",
|
||||
"reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"Text/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"include-path": [
|
||||
""
|
||||
],
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sb@sebastian-bergmann.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "Simple template engine.",
|
||||
"homepage": "https://github.com/sebastianbergmann/php-text-template/",
|
||||
"keywords": [
|
||||
"template"
|
||||
],
|
||||
"time": "2014-01-30 17:20:04"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-timer",
|
||||
"version": "1.0.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-timer.git",
|
||||
"reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c",
|
||||
"reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"PHP/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"include-path": [
|
||||
""
|
||||
],
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sb@sebastian-bergmann.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "Utility class for timing",
|
||||
"homepage": "https://github.com/sebastianbergmann/php-timer/",
|
||||
"keywords": [
|
||||
"timer"
|
||||
],
|
||||
"time": "2013-08-02 07:42:54"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-token-stream",
|
||||
"version": "1.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
|
||||
"reference": "f8d5d08c56de5cfd592b3340424a81733259a876"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/f8d5d08c56de5cfd592b3340424a81733259a876",
|
||||
"reference": "f8d5d08c56de5cfd592b3340424a81733259a876",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-tokenizer": "*",
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.2"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de"
|
||||
}
|
||||
],
|
||||
"description": "Wrapper around PHP's tokenizer extension.",
|
||||
"homepage": "https://github.com/sebastianbergmann/php-token-stream/",
|
||||
"keywords": [
|
||||
"tokenizer"
|
||||
],
|
||||
"time": "2014-08-31 06:12:13"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "4.1.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "241116219bb7e3b8111a36ffd8f37546888738d6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/241116219bb7e3b8111a36ffd8f37546888738d6",
|
||||
"reference": "241116219bb7e3b8111a36ffd8f37546888738d6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-dom": "*",
|
||||
"ext-json": "*",
|
||||
"ext-pcre": "*",
|
||||
"ext-reflection": "*",
|
||||
"ext-spl": "*",
|
||||
"php": ">=5.3.3",
|
||||
"phpunit/php-code-coverage": "~2.0",
|
||||
"phpunit/php-file-iterator": "~1.3.1",
|
||||
"phpunit/php-text-template": "~1.2",
|
||||
"phpunit/php-timer": "~1.0.2",
|
||||
"phpunit/phpunit-mock-objects": "2.1.5",
|
||||
"sebastian/comparator": "~1.0",
|
||||
"sebastian/diff": "~1.1",
|
||||
"sebastian/environment": "~1.0",
|
||||
"sebastian/exporter": "~1.0",
|
||||
"sebastian/version": "~1.0",
|
||||
"symfony/yaml": "~2.0"
|
||||
},
|
||||
"suggest": {
|
||||
"phpunit/php-invoker": "~1.1"
|
||||
},
|
||||
"bin": [
|
||||
"phpunit"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.1.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"include-path": [
|
||||
"",
|
||||
"../../symfony/yaml/"
|
||||
],
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "The PHP Unit Testing framework.",
|
||||
"homepage": "http://www.phpunit.de/",
|
||||
"keywords": [
|
||||
"phpunit",
|
||||
"testing",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2014-08-17 08:07:02"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit-mock-objects",
|
||||
"version": "2.1.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
|
||||
"reference": "7878b9c41edb3afab92b85edf5f0981014a2713a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/7878b9c41edb3afab92b85edf5f0981014a2713a",
|
||||
"reference": "7878b9c41edb3afab92b85edf5f0981014a2713a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"phpunit/php-text-template": "~1.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.1"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-soap": "*"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.1.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"include-path": [
|
||||
""
|
||||
],
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sb@sebastian-bergmann.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "Mock Object library for PHPUnit",
|
||||
"homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/",
|
||||
"keywords": [
|
||||
"mock",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2014-06-12 07:22:15"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/comparator",
|
||||
"version": "1.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/comparator.git",
|
||||
"reference": "e54a01c0da1b87db3c5a3c4c5277ddf331da4aef"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/e54a01c0da1b87db3c5a3c4c5277ddf331da4aef",
|
||||
"reference": "e54a01c0da1b87db3c5a3c4c5277ddf331da4aef",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"sebastian/diff": "~1.1",
|
||||
"sebastian/exporter": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.1"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jeff Welch",
|
||||
"email": "whatthejeff@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Volker Dusch",
|
||||
"email": "github@wallbash.com"
|
||||
},
|
||||
{
|
||||
"name": "Bernhard Schussek",
|
||||
"email": "bschussek@2bepublished.at"
|
||||
},
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de"
|
||||
}
|
||||
],
|
||||
"description": "Provides the functionality to compare PHP values for equality",
|
||||
"homepage": "http://www.github.com/sebastianbergmann/comparator",
|
||||
"keywords": [
|
||||
"comparator",
|
||||
"compare",
|
||||
"equality"
|
||||
],
|
||||
"time": "2014-05-11 23:00:21"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/diff",
|
||||
"version": "1.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/diff.git",
|
||||
"reference": "5843509fed39dee4b356a306401e9dd1a931fec7"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/5843509fed39dee4b356a306401e9dd1a931fec7",
|
||||
"reference": "5843509fed39dee4b356a306401e9dd1a931fec7",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.2"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.2-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kore Nordmann",
|
||||
"email": "mail@kore-nordmann.de"
|
||||
},
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de"
|
||||
}
|
||||
],
|
||||
"description": "Diff implementation",
|
||||
"homepage": "http://www.github.com/sebastianbergmann/diff",
|
||||
"keywords": [
|
||||
"diff"
|
||||
],
|
||||
"time": "2014-08-15 10:29:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/environment",
|
||||
"version": "1.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/environment.git",
|
||||
"reference": "0d9bf79554d2a999da194a60416c15cf461eb67d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/0d9bf79554d2a999da194a60416c15cf461eb67d",
|
||||
"reference": "0d9bf79554d2a999da194a60416c15cf461eb67d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.3"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.2.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de"
|
||||
}
|
||||
],
|
||||
"description": "Provides functionality to handle HHVM/PHP environments",
|
||||
"homepage": "http://www.github.com/sebastianbergmann/environment",
|
||||
"keywords": [
|
||||
"Xdebug",
|
||||
"environment",
|
||||
"hhvm"
|
||||
],
|
||||
"time": "2014-10-22 06:38:05"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/exporter",
|
||||
"version": "1.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/exporter.git",
|
||||
"reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/c7d59948d6e82818e1bdff7cadb6c34710eb7dc0",
|
||||
"reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jeff Welch",
|
||||
"email": "whatthejeff@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Volker Dusch",
|
||||
"email": "github@wallbash.com"
|
||||
},
|
||||
{
|
||||
"name": "Bernhard Schussek",
|
||||
"email": "bschussek@2bepublished.at"
|
||||
},
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de"
|
||||
},
|
||||
{
|
||||
"name": "Adam Harvey",
|
||||
"email": "aharvey@php.net"
|
||||
}
|
||||
],
|
||||
"description": "Provides the functionality to export PHP variables for visualization",
|
||||
"homepage": "http://www.github.com/sebastianbergmann/exporter",
|
||||
"keywords": [
|
||||
"export",
|
||||
"exporter"
|
||||
],
|
||||
"time": "2014-09-10 00:51:36"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/version",
|
||||
"version": "1.0.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/version.git",
|
||||
"reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/version/zipball/b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43",
|
||||
"reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43",
|
||||
"shasum": ""
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
|
||||
"homepage": "https://github.com/sebastianbergmann/version",
|
||||
"time": "2014-03-07 15:35:33"
|
||||
},
|
||||
{
|
||||
"name": "symfony/yaml",
|
||||
"version": "v2.5.6",
|
||||
"target-dir": "Symfony/Component/Yaml",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Yaml.git",
|
||||
"reference": "2d9f527449cabfa8543dd7fa3a466d6ae83d6726"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Yaml/zipball/2d9f527449cabfa8543dd7fa3a466d6ae83d6726",
|
||||
"reference": "2d9f527449cabfa8543dd7fa3a466d6ae83d6726",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.5-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Symfony\\Component\\Yaml\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://symfony.com/contributors"
|
||||
},
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Yaml Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2014-10-01 05:50:18"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
"prefer-stable": false,
|
||||
"platform": [],
|
||||
"platform-dev": []
|
||||
}
|
||||
17
core/vendor/thelia/math-tools/phpunit.xml.dist
vendored
Normal file
17
core/vendor/thelia/math-tools/phpunit.xml.dist
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit bootstrap="./tests/bootstrap.php"
|
||||
colors="true">
|
||||
<testsuites>
|
||||
<testsuite>
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">src</directory>
|
||||
<exclude>
|
||||
<directory suffix="Interface.php">src/</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
54
core/vendor/thelia/math-tools/src/GCD.php
vendored
Normal file
54
core/vendor/thelia/math-tools/src/GCD.php
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Math;
|
||||
|
||||
/**
|
||||
* Class GCD
|
||||
* @package Thelia\Math
|
||||
* @author Benjamin Perche <bperche@openstudio.com>
|
||||
*/
|
||||
class GCD
|
||||
{
|
||||
public static function getGCD($numberA, $numberB)
|
||||
{
|
||||
if (! self::isInteger($numberA) | ! self::isInteger($numberB)) {
|
||||
throw new \InvalidArgumentException(
|
||||
"GCD number must be an integer"
|
||||
);
|
||||
}
|
||||
|
||||
if (function_exists("gmp_gcd")) {
|
||||
return gmp_intval(gmp_gcd($numberA, $numberB));
|
||||
}
|
||||
|
||||
if ($numberA == 0 || $numberB == 0) {
|
||||
return max(abs($numberA), abs($numberB));
|
||||
}
|
||||
|
||||
$r = $numberA % $numberB;
|
||||
|
||||
return ($r != 0) ? self::getGCD($numberB, $r) : abs($numberB);
|
||||
}
|
||||
|
||||
public static function isInteger($var)
|
||||
{
|
||||
if (is_int($var)) {
|
||||
// the most obvious test
|
||||
return true;
|
||||
} elseif (is_numeric($var)) {
|
||||
// cast to string first
|
||||
return ctype_digit((string)$var);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
219
core/vendor/thelia/math-tools/src/Number.php
vendored
Normal file
219
core/vendor/thelia/math-tools/src/Number.php
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Math;
|
||||
|
||||
/**
|
||||
* Class Number
|
||||
* @package Lovenunu\Math
|
||||
* @author Benjamin Perche <bperche@openstudio.com>
|
||||
*/
|
||||
class Number implements \Serializable, \JsonSerializable
|
||||
{
|
||||
// Regex to find correct numbers
|
||||
const NUMBER_PATTERN = "#^\d+(\.\d+)?$#";
|
||||
|
||||
// Internal variables
|
||||
protected $dividend;
|
||||
|
||||
protected $divisor;
|
||||
|
||||
// --- Object construction ------------
|
||||
public function __construct($number = null)
|
||||
{
|
||||
list($this->dividend, $this->divisor) = $this->retrieve($number);
|
||||
}
|
||||
|
||||
protected function initialize($dividend, $divisor)
|
||||
{
|
||||
$this->dividend = $dividend;
|
||||
|
||||
$this->divisor = $divisor;
|
||||
}
|
||||
|
||||
// --- Number processor ------------
|
||||
|
||||
protected function retrieve($number)
|
||||
{
|
||||
$dividend = 0;
|
||||
$divisor = 1;
|
||||
|
||||
if ($number !== null) {
|
||||
if (is_scalar($number) && preg_match(static::NUMBER_PATTERN, $number)) {
|
||||
$dividend = (int) str_replace(".", "", $number);
|
||||
|
||||
if (false !== $pos = strpos($number, ".")) {
|
||||
$divisor = pow(10, strlen($number) - $pos - 1);
|
||||
}
|
||||
} elseif ($number instanceof $this) {
|
||||
$dividend = $number->getDividend();
|
||||
$divisor = $number->getDivisor();
|
||||
} else {
|
||||
throw new \InvalidArgumentException(
|
||||
"The given price is not valid"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return array($dividend, $divisor);
|
||||
}
|
||||
|
||||
protected function computeDividend($askedDividend, $askedDivisor, Number $number)
|
||||
{
|
||||
if ($number->divisor !== $askedDivisor) {
|
||||
$number->dividend *= $askedDivisor;
|
||||
$askedDividend *= $number->divisor;
|
||||
|
||||
$number->divisor *= $askedDivisor;
|
||||
}
|
||||
|
||||
return $askedDividend;
|
||||
}
|
||||
|
||||
protected function simplify()
|
||||
{
|
||||
if (1 < $gcd = GCD::getGCD($this->dividend, $this->divisor)) {
|
||||
$this->dividend /= $gcd;
|
||||
$this->divisor /= $gcd;
|
||||
}
|
||||
}
|
||||
|
||||
// --- Operations ------------
|
||||
|
||||
public function add($number)
|
||||
{
|
||||
list($askedDividend, $askedDivisor) = $this->retrieve($number);
|
||||
$returnNumber = clone $this;
|
||||
|
||||
$askedDividend = $this->computeDividend($askedDividend, $askedDivisor, $returnNumber);
|
||||
|
||||
/**
|
||||
* If divisors are different, just multiply them
|
||||
*/
|
||||
|
||||
$returnNumber->dividend += $askedDividend;
|
||||
$returnNumber->simplify();
|
||||
|
||||
return $returnNumber;
|
||||
}
|
||||
|
||||
public function sub($number)
|
||||
{
|
||||
list($askedDividend, $askedDivisor) = $this->retrieve($number);
|
||||
$returnNumber = clone $this;
|
||||
|
||||
$askedDividend = $this->computeDividend($askedDividend, $askedDivisor, $returnNumber);
|
||||
|
||||
/**
|
||||
* If divisors are different, just multiply them
|
||||
*/
|
||||
|
||||
$returnNumber->dividend -= $askedDividend;
|
||||
$returnNumber->simplify();
|
||||
|
||||
return $returnNumber;
|
||||
}
|
||||
|
||||
public function multiply($number)
|
||||
{
|
||||
list($askedDividend, $askedDivisor) = $this->retrieve($number);
|
||||
$returnNumber = clone $this;
|
||||
|
||||
$returnNumber->dividend *= $askedDividend;
|
||||
$returnNumber->divisor *= $askedDivisor;
|
||||
$returnNumber->simplify();
|
||||
|
||||
return $returnNumber;
|
||||
}
|
||||
|
||||
public function divide($number)
|
||||
{
|
||||
list($askedDividend, $askedDivisor) = $this->retrieve($number);
|
||||
$returnNumber = clone $this;
|
||||
|
||||
$returnNumber->dividend *= $askedDivisor;
|
||||
$returnNumber->divisor *= $askedDividend;
|
||||
$returnNumber->simplify();
|
||||
|
||||
return $returnNumber;
|
||||
}
|
||||
|
||||
// --- Results ------------
|
||||
|
||||
public function getNumber($roundPrecision = 2, $roundMode = PHP_ROUND_HALF_UP)
|
||||
{
|
||||
$value = $this->dividend / $this->divisor;
|
||||
|
||||
if ($roundPrecision >= 0) {
|
||||
$value = round($value, $roundPrecision, $roundMode);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
// --- Accessor ------------
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDividend()
|
||||
{
|
||||
return $this->dividend;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDivisor()
|
||||
{
|
||||
return $this->divisor;
|
||||
}
|
||||
|
||||
// --- Interfaces implementation ------------
|
||||
/**
|
||||
* (PHP 5 >= 5.1.0)<br/>
|
||||
* String representation of object
|
||||
* @link http://php.net/manual/en/serializable.serialize.php
|
||||
* @return string the string representation of the object or null
|
||||
*/
|
||||
public function serialize()
|
||||
{
|
||||
return json_encode(array($this->dividend, $this->divisor));
|
||||
}
|
||||
|
||||
/**
|
||||
* (PHP 5 >= 5.1.0)<br/>
|
||||
* Constructs the object
|
||||
* @link http://php.net/manual/en/serializable.unserialize.php
|
||||
* @param string $serialized <p>
|
||||
* The string representation of the object.
|
||||
* </p>
|
||||
* @return void
|
||||
*/
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
list($this->dividend, $this->divisor) = json_decode($serialized, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* (PHP 5 >= 5.4.0)<br/>
|
||||
* Specify data which should be serialized to JSON
|
||||
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
|
||||
* @return mixed data which can be serialized by <b>json_encode</b>,
|
||||
* which is a value of any type other than a resource.
|
||||
*/
|
||||
function jsonSerialize()
|
||||
{
|
||||
return $this->serialize();
|
||||
}
|
||||
|
||||
}
|
||||
61
core/vendor/thelia/math-tools/tests/Lovenunu/Math/NumberTest.php
vendored
Normal file
61
core/vendor/thelia/math-tools/tests/Lovenunu/Math/NumberTest.php
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
use Thelia\Math\Number;
|
||||
|
||||
/**
|
||||
* Class NumberTest
|
||||
* @author Benjamin Perche <bperche@openstudio.com>
|
||||
*/
|
||||
class NumberTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testMult()
|
||||
{
|
||||
$numberA = new Number('1');
|
||||
$numberB = $numberA->multiply('1.2393');
|
||||
|
||||
$this->assertEquals(1.2393, $numberB->getNumber(-1));
|
||||
}
|
||||
|
||||
public function testNumberAdd()
|
||||
{
|
||||
$numberA = new Number('1.99');
|
||||
$numberB = new Number('2.58');
|
||||
|
||||
$numberC = $numberA->add($numberB);
|
||||
|
||||
$this->assertEquals(4.57, $numberC->getNumber(-1));
|
||||
}
|
||||
|
||||
public function testNumberSub()
|
||||
{
|
||||
$price = new Number('1.99');
|
||||
|
||||
$subPrice = $price->sub('1.766');
|
||||
$this->assertEquals(0.22, $subPrice->getNumber());
|
||||
$this->assertEquals(1.99, $price->getNumber());
|
||||
$this->assertEquals(0.224, $subPrice->getNumber(3));
|
||||
$this->assertEquals(0.224, $subPrice->getNumber(-1));
|
||||
}
|
||||
|
||||
public function testNumberDivideThenMultiply()
|
||||
{
|
||||
$price = new Number('3.99');
|
||||
|
||||
$divPrice = $price->divide('1.2');
|
||||
$this->assertEquals(3.33, $divPrice->getNumber());
|
||||
|
||||
$mulPrice = $divPrice->multiply('1.2');
|
||||
$this->assertEquals(3.99, $mulPrice->getNumber());
|
||||
}
|
||||
}
|
||||
|
||||
3
core/vendor/thelia/math-tools/tests/bootstrap.php
vendored
Normal file
3
core/vendor/thelia/math-tools/tests/bootstrap.php
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
require __DIR__ . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "vendor" . DIRECTORY_SEPARATOR . "autoload.php";
|
||||
Reference in New Issue
Block a user