├── .editorconfig ├── .gitattributes ├── .gitignore ├── .scrutinizer.yml ├── .travis.yml ├── AUTHORS.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── ci_instance.php ├── composer.json ├── composer.lock ├── config └── currency_converter.php ├── libraries └── CurrencyConverter.php ├── models └── example_model.php ├── phpunit.php ├── phpunit.xml ├── tests ├── CurrencyConverterTest.php ├── currency_converter.php └── database.php └── version.md /.editorconfig: -------------------------------------------------------------------------------- 1 | # This file is for unifying the coding style for different editors and IDEs 2 | # editorconfig.org 3 | root = true 4 | 5 | [*] 6 | end_of_line = lf 7 | charset = utf-8 8 | indent_style = tab 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | 12 | [*.bat] 13 | end_of_line = crlf 14 | 15 | [*.yml] 16 | indent_style = space 17 | indent_size = 4 -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Define the line ending behavior of the different file extensions 2 | # Set default behaviour, in case users don't have core.autocrlf set. 3 | * text=auto 4 | * text eol=lf 5 | 6 | # Explicitly declare text files we want to always be normalized and converted 7 | # to native line endings on checkout. 8 | *.php text 9 | *.default text 10 | *.ctp text 11 | *.sql text 12 | *.md text 13 | *.po text 14 | *.js text 15 | *.css text 16 | *.ini text 17 | *.properties text 18 | *.txt text 19 | *.xml text 20 | *.yml text 21 | .htaccess text 22 | 23 | # Declare files that will always have CRLF line endings on checkout. 24 | *.bat eol=crlf 25 | 26 | # Declare files that will always have LF line endings on checkout. 27 | *.pem eol=lf 28 | 29 | # Denote all files that are truly binary and should not be modified. 30 | *.png binary 31 | *.jpg binary 32 | *.gif binary 33 | *.ico binary 34 | *.mo binary -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | */config/development 2 | */logs/log-*.php 3 | */logs/!index.html 4 | */cache/* 5 | */cache/!index.html 6 | */cache/!.htaccess 7 | vendor/ 8 | web/ -------------------------------------------------------------------------------- /.scrutinizer.yml: -------------------------------------------------------------------------------- 1 | build: 2 | environment: 3 | php: 4 | version: 5.6 5 | tests: 6 | override: 7 | - 8 | command: 'vendor/bin/phpunit --coverage-clover=some-file' 9 | coverage: 10 | file: 'some-file' 11 | format: 'clover' -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | php: 3 | - 5.6 4 | - 7.0 5 | - 7.1 6 | - 7.2 7 | - 7.3 8 | 9 | before_script: 10 | - composer self-update 11 | - composer install --prefer-dist --no-interaction --dev 12 | 13 | script: vendor/bin/phpunit --coverage-text 14 | -------------------------------------------------------------------------------- /AUTHORS.md: -------------------------------------------------------------------------------- 1 | Codeigniter-currency-converter is written and maintained with love by Alessandro Minoccheri 2 | 3 | Development Lead 4 | ```````````````` 5 | 6 | - Alessandro Minoccheri 7 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | When contributing to this repository, please first discuss the change you wish to make via issue, 4 | email, or any other method with the owners of this repository before making a change. 5 | 6 | Please note we have a code of conduct, please follow it in all your interactions with the project. 7 | 8 | ## Pull Request Process 9 | 10 | 1. Ensure any install or build dependencies are removed before the end of the layer when doing a 11 | build. 12 | 2. Update the README.md with details of changes to the interface, this includes new environment 13 | variables, exposed ports, useful file locations and container parameters. 14 | 3. Increase the version numbers in any examples files and the README.md to the new version that this 15 | Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/). 16 | 4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you 17 | do not have permission to do that, you may request the second reviewer to merge it for you. 18 | 19 | ## Code of Conduct 20 | 21 | ### Our Pledge 22 | 23 | In the interest of fostering an open and welcoming environment, we as 24 | contributors and maintainers pledge to making participation in our project and 25 | our community a harassment-free experience for everyone, regardless of age, body 26 | size, disability, ethnicity, gender identity and expression, level of experience, 27 | nationality, personal appearance, race, religion, or sexual identity and 28 | orientation. 29 | 30 | ### Our Standards 31 | 32 | Examples of behavior that contributes to creating a positive environment 33 | include: 34 | 35 | * Using welcoming and inclusive language 36 | * Being respectful of differing viewpoints and experiences 37 | * Gracefully accepting constructive criticism 38 | * Focusing on what is best for the community 39 | * Showing empathy towards other community members 40 | 41 | ### Our Responsibilities 42 | 43 | Project maintainers are responsible for clarifying the standards of acceptable 44 | behavior and are expected to take appropriate and fair corrective action in 45 | response to any instances of unacceptable behavior. 46 | 47 | Project maintainers have the right and responsibility to remove, edit, or 48 | reject comments, commits, code, wiki edits, issues, and other contributions 49 | that are not aligned to this Code of Conduct, or to ban temporarily or 50 | permanently any contributor for other behaviors that they deem inappropriate, 51 | threatening, offensive, or harmful. 52 | 53 | ### Scope 54 | 55 | This Code of Conduct applies both within project spaces and in public spaces 56 | when an individual is representing the project or its community. Examples of 57 | representing a project or community include using an official project e-mail 58 | address, posting via an official social media account, or acting as an appointed 59 | representative at an online or offline event. Representation of a project may be 60 | further defined and clarified by project maintainers. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Alessandro Minoccheri 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | codeigniter-currency-converter V 1.3.2 2 | ============================== 3 | 4 | [![Code Quality](https://scrutinizer-ci.com/g/alessandrominoccheri/codeigniter-currency-converter/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/alessandrominoccheri/codeigniter-currency-converter/badges/quality-score.png?b=master) 5 | [![Code Coverage](https://scrutinizer-ci.com/g/alessandrominoccheri/codeigniter-currency-converter/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/alessandrominoccheri/codeigniter-currency-converter/badges/coverage.png?b=master) 6 | [![Latest Stable Version](https://poser.pugx.org/alessandrominoccheri/codeigniter-currency-converter/v/stable.svg)](https://packagist.org/packages/alessandrominoccheri/codeigniter-currency-converter) 7 | [![License](https://poser.pugx.org/alessandrominoccheri/codeigniter-currency-converter/license.svg)](https://packagist.org/packages/alessandrominoccheri/codeigniter-currency-converter) 8 | [![Build Status](https://api.travis-ci.org/AlessandroMinoccheri/codeigniter-currency-converter.png)](https://travis-ci.org/AlessandroMinoccheri/codeigniter-currency-converter) 9 | [![Total Downloads](https://poser.pugx.org/alessandrominoccheri/codeigniter-currency-converter/d/total.png)](https://packagist.org/packages/alessandrominoccheri/codeigniter-currency-converter) 10 | 11 | A Codeigniter library to convert your price from a currency to another 12 | 13 | --- 14 | 15 | ## Background 16 | 17 | Is very frequently that inside your sites you need to convert your price from a currency to another. 18 | This library convert your price in every currency of the world. 19 | 20 | It works with fixer.io api and store currency rates inside the site database if you want. 21 | User can configure in hour the time of currency rates update, if the user doesn't want to use database, rates are updated every time with the current conversion. 22 | 23 | If you have set to use database, for example, user sets to update currency rates every hour, this library get the currency conversion from fixer.io the first time, store it inside the database and for the next hour it takes conversion rates from the database if exist. 24 | In this way reduce the request time to convert and every hour currency rates are updated. 25 | 26 | If you haven't set to use database, instead, every time you call the library it makes a request to fixer.io api and gets the actual conversion rate. This solution is great if you have not a lot of request. Instead, if you have a lot of conversion request is better to use the database configuration. 27 | 28 | 29 | --- 30 | 31 | 32 | ## Requirements 33 | 34 | * CodeIgniter 2.x or 3.x 35 | * PHP 5.3 or gretaer 36 | 37 | --- 38 | 39 | # Installation 40 | 41 | With composer you can install this package: 42 | 43 | ``` 44 | composer require alessandrominoccheri/codeigniter-currency-converter 45 | ``` 46 | 47 | Or Drag and drop the application/libraries/CurrencyConverter.php file into your application directories. Load it from your application/config/autoload.php using: 48 | 49 | ``` 50 | $autoload['libraries'] = array('database', 'CurrencyConverter'); 51 | ``` 52 | 53 | Or inside your model you can use: 54 | 55 | ``` 56 | $this->CurrencyConverter = new CurrencyConverter(); 57 | ``` 58 | 59 | It's important to have a valid database connection because the library saves conversion inside it if you want to use it. 60 | 61 | --- 62 | 63 | # Usage 64 | 65 | To convert your price you can make a request like this from your model / controller: 66 | 67 | ``` 68 | $result = $this->CurrencyConverter->convert('GBP', 'EUR', '2000.00', true, 1); 69 | ``` 70 | 71 | To get a list of currency code you can check here: 72 | 73 | [List of available currency code](http://www.xe.com/iso4217.php ) 74 | 75 | --- 76 | 77 | # Params 78 | 79 | The function declaration to retrieve your converted price is: 80 | 81 | ``` 82 | function convert($from_Currency, $to_Currency, $amount, $save_into_db = 1, $hour_difference = 1) 83 | ``` 84 | 85 | * fromCurrency: is the actual price currency (Example: EUR, GBP) 86 | * toCurrency: is the currency that you want to convert your price (Example: EUR, GBP) 87 | * amount: is the price to convert (Example: 200, 20) 88 | * saveIntoDb: is the variable that configure to use the database or not, if not hour_difference params is escaped 89 | * hourDifference: is the hour difference to update your currency conversion. For example if you have set to update currency rates every hour, this library get the currency conversion from fixer.io the first time, store it inside the database and for the next hour it takes conversion rates from the database if exist. 90 | 91 | --- 92 | 93 | 94 | # Api KEY 95 | 96 | To use this library you need to add your api key inside the configuration. 97 | to get your api key go to this site and generate it. 98 | 99 | [Generate your api key](https://www.currencyconverterapi.com/) 100 | 101 | --- 102 | ## License 103 | 104 | The MIT License (MIT) 105 | 106 | Copyright (c) 2014 Alessandro Minoccheri 107 | 108 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 109 | 110 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 111 | 112 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 113 | -------------------------------------------------------------------------------- /ci_instance.php: -------------------------------------------------------------------------------- 1 | 6 | * @license MIT License 7 | * @copyright 2015 Kenji Suzuki 8 | * @link https://github.com/kenjis/codeigniter-ss-twig 9 | * 10 | * Based on http://codeinphp.github.io/post/codeigniter-tip-accessing-codeigniter-instance-outside/ 11 | * Thanks! 12 | */ 13 | define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development'); 14 | $system_path = 'vendor/codeigniter/framework/system'; 15 | $application_folder = 'vendor/codeigniter/framework/application'; 16 | $doc_root = 'vendor/codeigniter/framework'; 17 | if (realpath($system_path) !== false) { 18 | $system_path = realpath($system_path) . '/'; 19 | } 20 | $system_path = rtrim($system_path, '/') . '/'; 21 | define('BASEPATH', str_replace("\\", "/", $system_path)); 22 | define('FCPATH', $doc_root . '/'); 23 | define('APPPATH', $application_folder . '/'); 24 | define('VIEWPATH', $application_folder . '/views/'); 25 | require(BASEPATH . 'core/Common.php'); 26 | if (file_exists(APPPATH . 'config/' . ENVIRONMENT . '/constants.php')) { 27 | require(APPPATH . 'config/' . ENVIRONMENT . '/constants.php'); 28 | } else { 29 | require(APPPATH . 'config/constants.php'); 30 | } 31 | $charset = strtoupper(config_item('charset')); 32 | ini_set('default_charset', $charset); 33 | if (extension_loaded('mbstring')) { 34 | define('MB_ENABLED', true); 35 | // mbstring.internal_encoding is deprecated starting with PHP 5.6 36 | // and it's usage triggers E_DEPRECATED messages. 37 | @ini_set('mbstring.internal_encoding', $charset); 38 | // This is required for mb_convert_encoding() to strip invalid characters. 39 | // That's utilized by CI_Utf8, but it's also done for consistency with iconv. 40 | mb_substitute_character('none'); 41 | } else { 42 | define('MB_ENABLED', false); 43 | } 44 | // There's an ICONV_IMPL constant, but the PHP manual says that using 45 | // iconv's predefined constants is "strongly discouraged". 46 | if (extension_loaded('iconv')) { 47 | define('ICONV_ENABLED', true); 48 | // iconv.internal_encoding is deprecated starting with PHP 5.6 49 | // and it's usage triggers E_DEPRECATED messages. 50 | @ini_set('iconv.internal_encoding', $charset); 51 | } else { 52 | define('ICONV_ENABLED', false); 53 | } 54 | $GLOBALS['CFG'] = & load_class('Config', 'core'); 55 | $GLOBALS['UNI'] = & load_class('Utf8', 'core'); 56 | $GLOBALS['SEC'] = & load_class('Security', 'core'); 57 | load_class('Loader', 'core'); 58 | load_class('Router', 'core'); 59 | load_class('Output', 'core'); 60 | load_class('Input', 'core'); 61 | load_class('Lang', 'core'); 62 | require(BASEPATH . 'core/Controller.php'); 63 | function &get_instance() 64 | { 65 | return CI_Controller::get_instance(); 66 | } 67 | return new CI_Controller(); -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "alessandrominoccheri/codeigniter-currency-converter", 3 | "type": "plugin", 4 | "description": "A Codeigniter library to convert your price from a currency to another", 5 | "keywords": ["codeigniter","currency", "price", "convert"], 6 | "homepage": "https://github.com/AlessandroMinoccheri/codeigniter-currency-converter", 7 | "license": "MIT", 8 | "authors": [ 9 | { 10 | "name": "Alessandro Minoccheri", 11 | "homepage": "http://alessandrominoccheri.com", 12 | "role": "Developer" 13 | } 14 | ], 15 | "require": { 16 | "php": ">=5.3.0" 17 | }, 18 | "require-dev": { 19 | "phpunit/phpunit": "3.7.*", 20 | "codeigniter/framework": "^2.0" 21 | }, 22 | "autoload": { 23 | "psr-4": { 24 | "": [ 25 | "libraries/", 26 | "tests/" 27 | ] 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "bf7e8ad3814f8c0b95cf8fde12d51398", 8 | "packages": [], 9 | "packages-dev": [ 10 | { 11 | "name": "codeigniter/framework", 12 | "version": "3.1.4", 13 | "source": { 14 | "type": "git", 15 | "url": "https://github.com/bcit-ci/CodeIgniter.git", 16 | "reference": "873608df8be83420474e3cf9fc749a8ed12a6c09" 17 | }, 18 | "dist": { 19 | "type": "zip", 20 | "url": "https://api.github.com/repos/bcit-ci/CodeIgniter/zipball/873608df8be83420474e3cf9fc749a8ed12a6c09", 21 | "reference": "873608df8be83420474e3cf9fc749a8ed12a6c09", 22 | "shasum": "" 23 | }, 24 | "require": { 25 | "php": ">=5.2.4" 26 | }, 27 | "require-dev": { 28 | "mikey179/vfsstream": "1.1.*", 29 | "phpunit/phpunit": "4.* || 5.*" 30 | }, 31 | "suggest": { 32 | "paragonie/random_compat": "Provides better randomness in PHP 5.x" 33 | }, 34 | "type": "project", 35 | "notification-url": "https://packagist.org/downloads/", 36 | "license": [ 37 | "MIT" 38 | ], 39 | "description": "The CodeIgniter framework", 40 | "homepage": "https://codeigniter.com", 41 | "time": "2017-03-20T15:51:08+00:00" 42 | }, 43 | { 44 | "name": "doctrine/instantiator", 45 | "version": "1.0.5", 46 | "source": { 47 | "type": "git", 48 | "url": "https://github.com/doctrine/instantiator.git", 49 | "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" 50 | }, 51 | "dist": { 52 | "type": "zip", 53 | "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", 54 | "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", 55 | "shasum": "" 56 | }, 57 | "require": { 58 | "php": ">=5.3,<8.0-DEV" 59 | }, 60 | "require-dev": { 61 | "athletic/athletic": "~0.1.8", 62 | "ext-pdo": "*", 63 | "ext-phar": "*", 64 | "phpunit/phpunit": "~4.0", 65 | "squizlabs/php_codesniffer": "~2.0" 66 | }, 67 | "type": "library", 68 | "extra": { 69 | "branch-alias": { 70 | "dev-master": "1.0.x-dev" 71 | } 72 | }, 73 | "autoload": { 74 | "psr-4": { 75 | "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" 76 | } 77 | }, 78 | "notification-url": "https://packagist.org/downloads/", 79 | "license": [ 80 | "MIT" 81 | ], 82 | "authors": [ 83 | { 84 | "name": "Marco Pivetta", 85 | "email": "ocramius@gmail.com", 86 | "homepage": "http://ocramius.github.com/" 87 | } 88 | ], 89 | "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", 90 | "homepage": "https://github.com/doctrine/instantiator", 91 | "keywords": [ 92 | "constructor", 93 | "instantiate" 94 | ], 95 | "time": "2015-06-14T21:17:01+00:00" 96 | }, 97 | { 98 | "name": "myclabs/deep-copy", 99 | "version": "1.6.1", 100 | "source": { 101 | "type": "git", 102 | "url": "https://github.com/myclabs/DeepCopy.git", 103 | "reference": "8e6e04167378abf1ddb4d3522d8755c5fd90d102" 104 | }, 105 | "dist": { 106 | "type": "zip", 107 | "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/8e6e04167378abf1ddb4d3522d8755c5fd90d102", 108 | "reference": "8e6e04167378abf1ddb4d3522d8755c5fd90d102", 109 | "shasum": "" 110 | }, 111 | "require": { 112 | "php": ">=5.4.0" 113 | }, 114 | "require-dev": { 115 | "doctrine/collections": "1.*", 116 | "phpunit/phpunit": "~4.1" 117 | }, 118 | "type": "library", 119 | "autoload": { 120 | "psr-4": { 121 | "DeepCopy\\": "src/DeepCopy/" 122 | } 123 | }, 124 | "notification-url": "https://packagist.org/downloads/", 125 | "license": [ 126 | "MIT" 127 | ], 128 | "description": "Create deep copies (clones) of your objects", 129 | "homepage": "https://github.com/myclabs/DeepCopy", 130 | "keywords": [ 131 | "clone", 132 | "copy", 133 | "duplicate", 134 | "object", 135 | "object graph" 136 | ], 137 | "time": "2017-04-12T18:52:22+00:00" 138 | }, 139 | { 140 | "name": "phpdocumentor/reflection-common", 141 | "version": "1.0", 142 | "source": { 143 | "type": "git", 144 | "url": "https://github.com/phpDocumentor/ReflectionCommon.git", 145 | "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c" 146 | }, 147 | "dist": { 148 | "type": "zip", 149 | "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/144c307535e82c8fdcaacbcfc1d6d8eeb896687c", 150 | "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c", 151 | "shasum": "" 152 | }, 153 | "require": { 154 | "php": ">=5.5" 155 | }, 156 | "require-dev": { 157 | "phpunit/phpunit": "^4.6" 158 | }, 159 | "type": "library", 160 | "extra": { 161 | "branch-alias": { 162 | "dev-master": "1.0.x-dev" 163 | } 164 | }, 165 | "autoload": { 166 | "psr-4": { 167 | "phpDocumentor\\Reflection\\": [ 168 | "src" 169 | ] 170 | } 171 | }, 172 | "notification-url": "https://packagist.org/downloads/", 173 | "license": [ 174 | "MIT" 175 | ], 176 | "authors": [ 177 | { 178 | "name": "Jaap van Otterdijk", 179 | "email": "opensource@ijaap.nl" 180 | } 181 | ], 182 | "description": "Common reflection classes used by phpdocumentor to reflect the code structure", 183 | "homepage": "http://www.phpdoc.org", 184 | "keywords": [ 185 | "FQSEN", 186 | "phpDocumentor", 187 | "phpdoc", 188 | "reflection", 189 | "static analysis" 190 | ], 191 | "time": "2015-12-27T11:43:31+00:00" 192 | }, 193 | { 194 | "name": "phpdocumentor/reflection-docblock", 195 | "version": "3.1.1", 196 | "source": { 197 | "type": "git", 198 | "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", 199 | "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e" 200 | }, 201 | "dist": { 202 | "type": "zip", 203 | "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/8331b5efe816ae05461b7ca1e721c01b46bafb3e", 204 | "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e", 205 | "shasum": "" 206 | }, 207 | "require": { 208 | "php": ">=5.5", 209 | "phpdocumentor/reflection-common": "^1.0@dev", 210 | "phpdocumentor/type-resolver": "^0.2.0", 211 | "webmozart/assert": "^1.0" 212 | }, 213 | "require-dev": { 214 | "mockery/mockery": "^0.9.4", 215 | "phpunit/phpunit": "^4.4" 216 | }, 217 | "type": "library", 218 | "autoload": { 219 | "psr-4": { 220 | "phpDocumentor\\Reflection\\": [ 221 | "src/" 222 | ] 223 | } 224 | }, 225 | "notification-url": "https://packagist.org/downloads/", 226 | "license": [ 227 | "MIT" 228 | ], 229 | "authors": [ 230 | { 231 | "name": "Mike van Riel", 232 | "email": "me@mikevanriel.com" 233 | } 234 | ], 235 | "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", 236 | "time": "2016-09-30T07:12:33+00:00" 237 | }, 238 | { 239 | "name": "phpdocumentor/type-resolver", 240 | "version": "0.2.1", 241 | "source": { 242 | "type": "git", 243 | "url": "https://github.com/phpDocumentor/TypeResolver.git", 244 | "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb" 245 | }, 246 | "dist": { 247 | "type": "zip", 248 | "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", 249 | "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", 250 | "shasum": "" 251 | }, 252 | "require": { 253 | "php": ">=5.5", 254 | "phpdocumentor/reflection-common": "^1.0" 255 | }, 256 | "require-dev": { 257 | "mockery/mockery": "^0.9.4", 258 | "phpunit/phpunit": "^5.2||^4.8.24" 259 | }, 260 | "type": "library", 261 | "extra": { 262 | "branch-alias": { 263 | "dev-master": "1.0.x-dev" 264 | } 265 | }, 266 | "autoload": { 267 | "psr-4": { 268 | "phpDocumentor\\Reflection\\": [ 269 | "src/" 270 | ] 271 | } 272 | }, 273 | "notification-url": "https://packagist.org/downloads/", 274 | "license": [ 275 | "MIT" 276 | ], 277 | "authors": [ 278 | { 279 | "name": "Mike van Riel", 280 | "email": "me@mikevanriel.com" 281 | } 282 | ], 283 | "time": "2016-11-25T06:54:22+00:00" 284 | }, 285 | { 286 | "name": "phpspec/prophecy", 287 | "version": "v1.7.0", 288 | "source": { 289 | "type": "git", 290 | "url": "https://github.com/phpspec/prophecy.git", 291 | "reference": "93d39f1f7f9326d746203c7c056f300f7f126073" 292 | }, 293 | "dist": { 294 | "type": "zip", 295 | "url": "https://api.github.com/repos/phpspec/prophecy/zipball/93d39f1f7f9326d746203c7c056f300f7f126073", 296 | "reference": "93d39f1f7f9326d746203c7c056f300f7f126073", 297 | "shasum": "" 298 | }, 299 | "require": { 300 | "doctrine/instantiator": "^1.0.2", 301 | "php": "^5.3|^7.0", 302 | "phpdocumentor/reflection-docblock": "^2.0|^3.0.2", 303 | "sebastian/comparator": "^1.1|^2.0", 304 | "sebastian/recursion-context": "^1.0|^2.0|^3.0" 305 | }, 306 | "require-dev": { 307 | "phpspec/phpspec": "^2.5|^3.2", 308 | "phpunit/phpunit": "^4.8 || ^5.6.5" 309 | }, 310 | "type": "library", 311 | "extra": { 312 | "branch-alias": { 313 | "dev-master": "1.6.x-dev" 314 | } 315 | }, 316 | "autoload": { 317 | "psr-0": { 318 | "Prophecy\\": "src/" 319 | } 320 | }, 321 | "notification-url": "https://packagist.org/downloads/", 322 | "license": [ 323 | "MIT" 324 | ], 325 | "authors": [ 326 | { 327 | "name": "Konstantin Kudryashov", 328 | "email": "ever.zet@gmail.com", 329 | "homepage": "http://everzet.com" 330 | }, 331 | { 332 | "name": "Marcello Duarte", 333 | "email": "marcello.duarte@gmail.com" 334 | } 335 | ], 336 | "description": "Highly opinionated mocking framework for PHP 5.3+", 337 | "homepage": "https://github.com/phpspec/prophecy", 338 | "keywords": [ 339 | "Double", 340 | "Dummy", 341 | "fake", 342 | "mock", 343 | "spy", 344 | "stub" 345 | ], 346 | "time": "2017-03-02T20:05:34+00:00" 347 | }, 348 | { 349 | "name": "phpunit/php-code-coverage", 350 | "version": "4.0.8", 351 | "source": { 352 | "type": "git", 353 | "url": "https://github.com/sebastianbergmann/php-code-coverage.git", 354 | "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d" 355 | }, 356 | "dist": { 357 | "type": "zip", 358 | "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef7b2f56815df854e66ceaee8ebe9393ae36a40d", 359 | "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d", 360 | "shasum": "" 361 | }, 362 | "require": { 363 | "ext-dom": "*", 364 | "ext-xmlwriter": "*", 365 | "php": "^5.6 || ^7.0", 366 | "phpunit/php-file-iterator": "^1.3", 367 | "phpunit/php-text-template": "^1.2", 368 | "phpunit/php-token-stream": "^1.4.2 || ^2.0", 369 | "sebastian/code-unit-reverse-lookup": "^1.0", 370 | "sebastian/environment": "^1.3.2 || ^2.0", 371 | "sebastian/version": "^1.0 || ^2.0" 372 | }, 373 | "require-dev": { 374 | "ext-xdebug": "^2.1.4", 375 | "phpunit/phpunit": "^5.7" 376 | }, 377 | "suggest": { 378 | "ext-xdebug": "^2.5.1" 379 | }, 380 | "type": "library", 381 | "extra": { 382 | "branch-alias": { 383 | "dev-master": "4.0.x-dev" 384 | } 385 | }, 386 | "autoload": { 387 | "classmap": [ 388 | "src/" 389 | ] 390 | }, 391 | "notification-url": "https://packagist.org/downloads/", 392 | "license": [ 393 | "BSD-3-Clause" 394 | ], 395 | "authors": [ 396 | { 397 | "name": "Sebastian Bergmann", 398 | "email": "sb@sebastian-bergmann.de", 399 | "role": "lead" 400 | } 401 | ], 402 | "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", 403 | "homepage": "https://github.com/sebastianbergmann/php-code-coverage", 404 | "keywords": [ 405 | "coverage", 406 | "testing", 407 | "xunit" 408 | ], 409 | "time": "2017-04-02T07:44:40+00:00" 410 | }, 411 | { 412 | "name": "phpunit/php-file-iterator", 413 | "version": "1.4.2", 414 | "source": { 415 | "type": "git", 416 | "url": "https://github.com/sebastianbergmann/php-file-iterator.git", 417 | "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" 418 | }, 419 | "dist": { 420 | "type": "zip", 421 | "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", 422 | "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", 423 | "shasum": "" 424 | }, 425 | "require": { 426 | "php": ">=5.3.3" 427 | }, 428 | "type": "library", 429 | "extra": { 430 | "branch-alias": { 431 | "dev-master": "1.4.x-dev" 432 | } 433 | }, 434 | "autoload": { 435 | "classmap": [ 436 | "src/" 437 | ] 438 | }, 439 | "notification-url": "https://packagist.org/downloads/", 440 | "license": [ 441 | "BSD-3-Clause" 442 | ], 443 | "authors": [ 444 | { 445 | "name": "Sebastian Bergmann", 446 | "email": "sb@sebastian-bergmann.de", 447 | "role": "lead" 448 | } 449 | ], 450 | "description": "FilterIterator implementation that filters files based on a list of suffixes.", 451 | "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", 452 | "keywords": [ 453 | "filesystem", 454 | "iterator" 455 | ], 456 | "time": "2016-10-03T07:40:28+00:00" 457 | }, 458 | { 459 | "name": "phpunit/php-text-template", 460 | "version": "1.2.1", 461 | "source": { 462 | "type": "git", 463 | "url": "https://github.com/sebastianbergmann/php-text-template.git", 464 | "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" 465 | }, 466 | "dist": { 467 | "type": "zip", 468 | "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", 469 | "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", 470 | "shasum": "" 471 | }, 472 | "require": { 473 | "php": ">=5.3.3" 474 | }, 475 | "type": "library", 476 | "autoload": { 477 | "classmap": [ 478 | "src/" 479 | ] 480 | }, 481 | "notification-url": "https://packagist.org/downloads/", 482 | "license": [ 483 | "BSD-3-Clause" 484 | ], 485 | "authors": [ 486 | { 487 | "name": "Sebastian Bergmann", 488 | "email": "sebastian@phpunit.de", 489 | "role": "lead" 490 | } 491 | ], 492 | "description": "Simple template engine.", 493 | "homepage": "https://github.com/sebastianbergmann/php-text-template/", 494 | "keywords": [ 495 | "template" 496 | ], 497 | "time": "2015-06-21T13:50:34+00:00" 498 | }, 499 | { 500 | "name": "phpunit/php-timer", 501 | "version": "1.0.9", 502 | "source": { 503 | "type": "git", 504 | "url": "https://github.com/sebastianbergmann/php-timer.git", 505 | "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" 506 | }, 507 | "dist": { 508 | "type": "zip", 509 | "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", 510 | "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", 511 | "shasum": "" 512 | }, 513 | "require": { 514 | "php": "^5.3.3 || ^7.0" 515 | }, 516 | "require-dev": { 517 | "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" 518 | }, 519 | "type": "library", 520 | "extra": { 521 | "branch-alias": { 522 | "dev-master": "1.0-dev" 523 | } 524 | }, 525 | "autoload": { 526 | "classmap": [ 527 | "src/" 528 | ] 529 | }, 530 | "notification-url": "https://packagist.org/downloads/", 531 | "license": [ 532 | "BSD-3-Clause" 533 | ], 534 | "authors": [ 535 | { 536 | "name": "Sebastian Bergmann", 537 | "email": "sb@sebastian-bergmann.de", 538 | "role": "lead" 539 | } 540 | ], 541 | "description": "Utility class for timing", 542 | "homepage": "https://github.com/sebastianbergmann/php-timer/", 543 | "keywords": [ 544 | "timer" 545 | ], 546 | "time": "2017-02-26T11:10:40+00:00" 547 | }, 548 | { 549 | "name": "phpunit/php-token-stream", 550 | "version": "1.4.11", 551 | "source": { 552 | "type": "git", 553 | "url": "https://github.com/sebastianbergmann/php-token-stream.git", 554 | "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7" 555 | }, 556 | "dist": { 557 | "type": "zip", 558 | "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e03f8f67534427a787e21a385a67ec3ca6978ea7", 559 | "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7", 560 | "shasum": "" 561 | }, 562 | "require": { 563 | "ext-tokenizer": "*", 564 | "php": ">=5.3.3" 565 | }, 566 | "require-dev": { 567 | "phpunit/phpunit": "~4.2" 568 | }, 569 | "type": "library", 570 | "extra": { 571 | "branch-alias": { 572 | "dev-master": "1.4-dev" 573 | } 574 | }, 575 | "autoload": { 576 | "classmap": [ 577 | "src/" 578 | ] 579 | }, 580 | "notification-url": "https://packagist.org/downloads/", 581 | "license": [ 582 | "BSD-3-Clause" 583 | ], 584 | "authors": [ 585 | { 586 | "name": "Sebastian Bergmann", 587 | "email": "sebastian@phpunit.de" 588 | } 589 | ], 590 | "description": "Wrapper around PHP's tokenizer extension.", 591 | "homepage": "https://github.com/sebastianbergmann/php-token-stream/", 592 | "keywords": [ 593 | "tokenizer" 594 | ], 595 | "time": "2017-02-27T10:12:30+00:00" 596 | }, 597 | { 598 | "name": "phpunit/phpunit", 599 | "version": "5.7.19", 600 | "source": { 601 | "type": "git", 602 | "url": "https://github.com/sebastianbergmann/phpunit.git", 603 | "reference": "69c4f49ff376af2692bad9cebd883d17ebaa98a1" 604 | }, 605 | "dist": { 606 | "type": "zip", 607 | "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/69c4f49ff376af2692bad9cebd883d17ebaa98a1", 608 | "reference": "69c4f49ff376af2692bad9cebd883d17ebaa98a1", 609 | "shasum": "" 610 | }, 611 | "require": { 612 | "ext-dom": "*", 613 | "ext-json": "*", 614 | "ext-libxml": "*", 615 | "ext-mbstring": "*", 616 | "ext-xml": "*", 617 | "myclabs/deep-copy": "~1.3", 618 | "php": "^5.6 || ^7.0", 619 | "phpspec/prophecy": "^1.6.2", 620 | "phpunit/php-code-coverage": "^4.0.4", 621 | "phpunit/php-file-iterator": "~1.4", 622 | "phpunit/php-text-template": "~1.2", 623 | "phpunit/php-timer": "^1.0.6", 624 | "phpunit/phpunit-mock-objects": "^3.2", 625 | "sebastian/comparator": "^1.2.4", 626 | "sebastian/diff": "~1.2", 627 | "sebastian/environment": "^1.3.4 || ^2.0", 628 | "sebastian/exporter": "~2.0", 629 | "sebastian/global-state": "^1.1", 630 | "sebastian/object-enumerator": "~2.0", 631 | "sebastian/resource-operations": "~1.0", 632 | "sebastian/version": "~1.0.3|~2.0", 633 | "symfony/yaml": "~2.1|~3.0" 634 | }, 635 | "conflict": { 636 | "phpdocumentor/reflection-docblock": "3.0.2" 637 | }, 638 | "require-dev": { 639 | "ext-pdo": "*" 640 | }, 641 | "suggest": { 642 | "ext-xdebug": "*", 643 | "phpunit/php-invoker": "~1.1" 644 | }, 645 | "bin": [ 646 | "phpunit" 647 | ], 648 | "type": "library", 649 | "extra": { 650 | "branch-alias": { 651 | "dev-master": "5.7.x-dev" 652 | } 653 | }, 654 | "autoload": { 655 | "classmap": [ 656 | "src/" 657 | ] 658 | }, 659 | "notification-url": "https://packagist.org/downloads/", 660 | "license": [ 661 | "BSD-3-Clause" 662 | ], 663 | "authors": [ 664 | { 665 | "name": "Sebastian Bergmann", 666 | "email": "sebastian@phpunit.de", 667 | "role": "lead" 668 | } 669 | ], 670 | "description": "The PHP Unit Testing framework.", 671 | "homepage": "https://phpunit.de/", 672 | "keywords": [ 673 | "phpunit", 674 | "testing", 675 | "xunit" 676 | ], 677 | "time": "2017-04-03T02:22:27+00:00" 678 | }, 679 | { 680 | "name": "phpunit/phpunit-mock-objects", 681 | "version": "3.4.3", 682 | "source": { 683 | "type": "git", 684 | "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", 685 | "reference": "3ab72b65b39b491e0c011e2e09bb2206c2aa8e24" 686 | }, 687 | "dist": { 688 | "type": "zip", 689 | "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/3ab72b65b39b491e0c011e2e09bb2206c2aa8e24", 690 | "reference": "3ab72b65b39b491e0c011e2e09bb2206c2aa8e24", 691 | "shasum": "" 692 | }, 693 | "require": { 694 | "doctrine/instantiator": "^1.0.2", 695 | "php": "^5.6 || ^7.0", 696 | "phpunit/php-text-template": "^1.2", 697 | "sebastian/exporter": "^1.2 || ^2.0" 698 | }, 699 | "conflict": { 700 | "phpunit/phpunit": "<5.4.0" 701 | }, 702 | "require-dev": { 703 | "phpunit/phpunit": "^5.4" 704 | }, 705 | "suggest": { 706 | "ext-soap": "*" 707 | }, 708 | "type": "library", 709 | "extra": { 710 | "branch-alias": { 711 | "dev-master": "3.2.x-dev" 712 | } 713 | }, 714 | "autoload": { 715 | "classmap": [ 716 | "src/" 717 | ] 718 | }, 719 | "notification-url": "https://packagist.org/downloads/", 720 | "license": [ 721 | "BSD-3-Clause" 722 | ], 723 | "authors": [ 724 | { 725 | "name": "Sebastian Bergmann", 726 | "email": "sb@sebastian-bergmann.de", 727 | "role": "lead" 728 | } 729 | ], 730 | "description": "Mock Object library for PHPUnit", 731 | "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", 732 | "keywords": [ 733 | "mock", 734 | "xunit" 735 | ], 736 | "time": "2016-12-08T20:27:08+00:00" 737 | }, 738 | { 739 | "name": "sebastian/code-unit-reverse-lookup", 740 | "version": "1.0.1", 741 | "source": { 742 | "type": "git", 743 | "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", 744 | "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" 745 | }, 746 | "dist": { 747 | "type": "zip", 748 | "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", 749 | "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", 750 | "shasum": "" 751 | }, 752 | "require": { 753 | "php": "^5.6 || ^7.0" 754 | }, 755 | "require-dev": { 756 | "phpunit/phpunit": "^5.7 || ^6.0" 757 | }, 758 | "type": "library", 759 | "extra": { 760 | "branch-alias": { 761 | "dev-master": "1.0.x-dev" 762 | } 763 | }, 764 | "autoload": { 765 | "classmap": [ 766 | "src/" 767 | ] 768 | }, 769 | "notification-url": "https://packagist.org/downloads/", 770 | "license": [ 771 | "BSD-3-Clause" 772 | ], 773 | "authors": [ 774 | { 775 | "name": "Sebastian Bergmann", 776 | "email": "sebastian@phpunit.de" 777 | } 778 | ], 779 | "description": "Looks up which function or method a line of code belongs to", 780 | "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", 781 | "time": "2017-03-04T06:30:41+00:00" 782 | }, 783 | { 784 | "name": "sebastian/comparator", 785 | "version": "1.2.4", 786 | "source": { 787 | "type": "git", 788 | "url": "https://github.com/sebastianbergmann/comparator.git", 789 | "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" 790 | }, 791 | "dist": { 792 | "type": "zip", 793 | "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", 794 | "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", 795 | "shasum": "" 796 | }, 797 | "require": { 798 | "php": ">=5.3.3", 799 | "sebastian/diff": "~1.2", 800 | "sebastian/exporter": "~1.2 || ~2.0" 801 | }, 802 | "require-dev": { 803 | "phpunit/phpunit": "~4.4" 804 | }, 805 | "type": "library", 806 | "extra": { 807 | "branch-alias": { 808 | "dev-master": "1.2.x-dev" 809 | } 810 | }, 811 | "autoload": { 812 | "classmap": [ 813 | "src/" 814 | ] 815 | }, 816 | "notification-url": "https://packagist.org/downloads/", 817 | "license": [ 818 | "BSD-3-Clause" 819 | ], 820 | "authors": [ 821 | { 822 | "name": "Jeff Welch", 823 | "email": "whatthejeff@gmail.com" 824 | }, 825 | { 826 | "name": "Volker Dusch", 827 | "email": "github@wallbash.com" 828 | }, 829 | { 830 | "name": "Bernhard Schussek", 831 | "email": "bschussek@2bepublished.at" 832 | }, 833 | { 834 | "name": "Sebastian Bergmann", 835 | "email": "sebastian@phpunit.de" 836 | } 837 | ], 838 | "description": "Provides the functionality to compare PHP values for equality", 839 | "homepage": "http://www.github.com/sebastianbergmann/comparator", 840 | "keywords": [ 841 | "comparator", 842 | "compare", 843 | "equality" 844 | ], 845 | "time": "2017-01-29T09:50:25+00:00" 846 | }, 847 | { 848 | "name": "sebastian/diff", 849 | "version": "1.4.1", 850 | "source": { 851 | "type": "git", 852 | "url": "https://github.com/sebastianbergmann/diff.git", 853 | "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e" 854 | }, 855 | "dist": { 856 | "type": "zip", 857 | "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/13edfd8706462032c2f52b4b862974dd46b71c9e", 858 | "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e", 859 | "shasum": "" 860 | }, 861 | "require": { 862 | "php": ">=5.3.3" 863 | }, 864 | "require-dev": { 865 | "phpunit/phpunit": "~4.8" 866 | }, 867 | "type": "library", 868 | "extra": { 869 | "branch-alias": { 870 | "dev-master": "1.4-dev" 871 | } 872 | }, 873 | "autoload": { 874 | "classmap": [ 875 | "src/" 876 | ] 877 | }, 878 | "notification-url": "https://packagist.org/downloads/", 879 | "license": [ 880 | "BSD-3-Clause" 881 | ], 882 | "authors": [ 883 | { 884 | "name": "Kore Nordmann", 885 | "email": "mail@kore-nordmann.de" 886 | }, 887 | { 888 | "name": "Sebastian Bergmann", 889 | "email": "sebastian@phpunit.de" 890 | } 891 | ], 892 | "description": "Diff implementation", 893 | "homepage": "https://github.com/sebastianbergmann/diff", 894 | "keywords": [ 895 | "diff" 896 | ], 897 | "time": "2015-12-08T07:14:41+00:00" 898 | }, 899 | { 900 | "name": "sebastian/environment", 901 | "version": "2.0.0", 902 | "source": { 903 | "type": "git", 904 | "url": "https://github.com/sebastianbergmann/environment.git", 905 | "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac" 906 | }, 907 | "dist": { 908 | "type": "zip", 909 | "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5795ffe5dc5b02460c3e34222fee8cbe245d8fac", 910 | "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac", 911 | "shasum": "" 912 | }, 913 | "require": { 914 | "php": "^5.6 || ^7.0" 915 | }, 916 | "require-dev": { 917 | "phpunit/phpunit": "^5.0" 918 | }, 919 | "type": "library", 920 | "extra": { 921 | "branch-alias": { 922 | "dev-master": "2.0.x-dev" 923 | } 924 | }, 925 | "autoload": { 926 | "classmap": [ 927 | "src/" 928 | ] 929 | }, 930 | "notification-url": "https://packagist.org/downloads/", 931 | "license": [ 932 | "BSD-3-Clause" 933 | ], 934 | "authors": [ 935 | { 936 | "name": "Sebastian Bergmann", 937 | "email": "sebastian@phpunit.de" 938 | } 939 | ], 940 | "description": "Provides functionality to handle HHVM/PHP environments", 941 | "homepage": "http://www.github.com/sebastianbergmann/environment", 942 | "keywords": [ 943 | "Xdebug", 944 | "environment", 945 | "hhvm" 946 | ], 947 | "time": "2016-11-26T07:53:53+00:00" 948 | }, 949 | { 950 | "name": "sebastian/exporter", 951 | "version": "2.0.0", 952 | "source": { 953 | "type": "git", 954 | "url": "https://github.com/sebastianbergmann/exporter.git", 955 | "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4" 956 | }, 957 | "dist": { 958 | "type": "zip", 959 | "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", 960 | "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", 961 | "shasum": "" 962 | }, 963 | "require": { 964 | "php": ">=5.3.3", 965 | "sebastian/recursion-context": "~2.0" 966 | }, 967 | "require-dev": { 968 | "ext-mbstring": "*", 969 | "phpunit/phpunit": "~4.4" 970 | }, 971 | "type": "library", 972 | "extra": { 973 | "branch-alias": { 974 | "dev-master": "2.0.x-dev" 975 | } 976 | }, 977 | "autoload": { 978 | "classmap": [ 979 | "src/" 980 | ] 981 | }, 982 | "notification-url": "https://packagist.org/downloads/", 983 | "license": [ 984 | "BSD-3-Clause" 985 | ], 986 | "authors": [ 987 | { 988 | "name": "Jeff Welch", 989 | "email": "whatthejeff@gmail.com" 990 | }, 991 | { 992 | "name": "Volker Dusch", 993 | "email": "github@wallbash.com" 994 | }, 995 | { 996 | "name": "Bernhard Schussek", 997 | "email": "bschussek@2bepublished.at" 998 | }, 999 | { 1000 | "name": "Sebastian Bergmann", 1001 | "email": "sebastian@phpunit.de" 1002 | }, 1003 | { 1004 | "name": "Adam Harvey", 1005 | "email": "aharvey@php.net" 1006 | } 1007 | ], 1008 | "description": "Provides the functionality to export PHP variables for visualization", 1009 | "homepage": "http://www.github.com/sebastianbergmann/exporter", 1010 | "keywords": [ 1011 | "export", 1012 | "exporter" 1013 | ], 1014 | "time": "2016-11-19T08:54:04+00:00" 1015 | }, 1016 | { 1017 | "name": "sebastian/global-state", 1018 | "version": "1.1.1", 1019 | "source": { 1020 | "type": "git", 1021 | "url": "https://github.com/sebastianbergmann/global-state.git", 1022 | "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" 1023 | }, 1024 | "dist": { 1025 | "type": "zip", 1026 | "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", 1027 | "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", 1028 | "shasum": "" 1029 | }, 1030 | "require": { 1031 | "php": ">=5.3.3" 1032 | }, 1033 | "require-dev": { 1034 | "phpunit/phpunit": "~4.2" 1035 | }, 1036 | "suggest": { 1037 | "ext-uopz": "*" 1038 | }, 1039 | "type": "library", 1040 | "extra": { 1041 | "branch-alias": { 1042 | "dev-master": "1.0-dev" 1043 | } 1044 | }, 1045 | "autoload": { 1046 | "classmap": [ 1047 | "src/" 1048 | ] 1049 | }, 1050 | "notification-url": "https://packagist.org/downloads/", 1051 | "license": [ 1052 | "BSD-3-Clause" 1053 | ], 1054 | "authors": [ 1055 | { 1056 | "name": "Sebastian Bergmann", 1057 | "email": "sebastian@phpunit.de" 1058 | } 1059 | ], 1060 | "description": "Snapshotting of global state", 1061 | "homepage": "http://www.github.com/sebastianbergmann/global-state", 1062 | "keywords": [ 1063 | "global state" 1064 | ], 1065 | "time": "2015-10-12T03:26:01+00:00" 1066 | }, 1067 | { 1068 | "name": "sebastian/object-enumerator", 1069 | "version": "2.0.1", 1070 | "source": { 1071 | "type": "git", 1072 | "url": "https://github.com/sebastianbergmann/object-enumerator.git", 1073 | "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7" 1074 | }, 1075 | "dist": { 1076 | "type": "zip", 1077 | "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/1311872ac850040a79c3c058bea3e22d0f09cbb7", 1078 | "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7", 1079 | "shasum": "" 1080 | }, 1081 | "require": { 1082 | "php": ">=5.6", 1083 | "sebastian/recursion-context": "~2.0" 1084 | }, 1085 | "require-dev": { 1086 | "phpunit/phpunit": "~5" 1087 | }, 1088 | "type": "library", 1089 | "extra": { 1090 | "branch-alias": { 1091 | "dev-master": "2.0.x-dev" 1092 | } 1093 | }, 1094 | "autoload": { 1095 | "classmap": [ 1096 | "src/" 1097 | ] 1098 | }, 1099 | "notification-url": "https://packagist.org/downloads/", 1100 | "license": [ 1101 | "BSD-3-Clause" 1102 | ], 1103 | "authors": [ 1104 | { 1105 | "name": "Sebastian Bergmann", 1106 | "email": "sebastian@phpunit.de" 1107 | } 1108 | ], 1109 | "description": "Traverses array structures and object graphs to enumerate all referenced objects", 1110 | "homepage": "https://github.com/sebastianbergmann/object-enumerator/", 1111 | "time": "2017-02-18T15:18:39+00:00" 1112 | }, 1113 | { 1114 | "name": "sebastian/recursion-context", 1115 | "version": "2.0.0", 1116 | "source": { 1117 | "type": "git", 1118 | "url": "https://github.com/sebastianbergmann/recursion-context.git", 1119 | "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a" 1120 | }, 1121 | "dist": { 1122 | "type": "zip", 1123 | "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/2c3ba150cbec723aa057506e73a8d33bdb286c9a", 1124 | "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a", 1125 | "shasum": "" 1126 | }, 1127 | "require": { 1128 | "php": ">=5.3.3" 1129 | }, 1130 | "require-dev": { 1131 | "phpunit/phpunit": "~4.4" 1132 | }, 1133 | "type": "library", 1134 | "extra": { 1135 | "branch-alias": { 1136 | "dev-master": "2.0.x-dev" 1137 | } 1138 | }, 1139 | "autoload": { 1140 | "classmap": [ 1141 | "src/" 1142 | ] 1143 | }, 1144 | "notification-url": "https://packagist.org/downloads/", 1145 | "license": [ 1146 | "BSD-3-Clause" 1147 | ], 1148 | "authors": [ 1149 | { 1150 | "name": "Jeff Welch", 1151 | "email": "whatthejeff@gmail.com" 1152 | }, 1153 | { 1154 | "name": "Sebastian Bergmann", 1155 | "email": "sebastian@phpunit.de" 1156 | }, 1157 | { 1158 | "name": "Adam Harvey", 1159 | "email": "aharvey@php.net" 1160 | } 1161 | ], 1162 | "description": "Provides functionality to recursively process PHP variables", 1163 | "homepage": "http://www.github.com/sebastianbergmann/recursion-context", 1164 | "time": "2016-11-19T07:33:16+00:00" 1165 | }, 1166 | { 1167 | "name": "sebastian/resource-operations", 1168 | "version": "1.0.0", 1169 | "source": { 1170 | "type": "git", 1171 | "url": "https://github.com/sebastianbergmann/resource-operations.git", 1172 | "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" 1173 | }, 1174 | "dist": { 1175 | "type": "zip", 1176 | "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", 1177 | "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", 1178 | "shasum": "" 1179 | }, 1180 | "require": { 1181 | "php": ">=5.6.0" 1182 | }, 1183 | "type": "library", 1184 | "extra": { 1185 | "branch-alias": { 1186 | "dev-master": "1.0.x-dev" 1187 | } 1188 | }, 1189 | "autoload": { 1190 | "classmap": [ 1191 | "src/" 1192 | ] 1193 | }, 1194 | "notification-url": "https://packagist.org/downloads/", 1195 | "license": [ 1196 | "BSD-3-Clause" 1197 | ], 1198 | "authors": [ 1199 | { 1200 | "name": "Sebastian Bergmann", 1201 | "email": "sebastian@phpunit.de" 1202 | } 1203 | ], 1204 | "description": "Provides a list of PHP built-in functions that operate on resources", 1205 | "homepage": "https://www.github.com/sebastianbergmann/resource-operations", 1206 | "time": "2015-07-28T20:34:47+00:00" 1207 | }, 1208 | { 1209 | "name": "sebastian/version", 1210 | "version": "2.0.1", 1211 | "source": { 1212 | "type": "git", 1213 | "url": "https://github.com/sebastianbergmann/version.git", 1214 | "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" 1215 | }, 1216 | "dist": { 1217 | "type": "zip", 1218 | "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", 1219 | "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", 1220 | "shasum": "" 1221 | }, 1222 | "require": { 1223 | "php": ">=5.6" 1224 | }, 1225 | "type": "library", 1226 | "extra": { 1227 | "branch-alias": { 1228 | "dev-master": "2.0.x-dev" 1229 | } 1230 | }, 1231 | "autoload": { 1232 | "classmap": [ 1233 | "src/" 1234 | ] 1235 | }, 1236 | "notification-url": "https://packagist.org/downloads/", 1237 | "license": [ 1238 | "BSD-3-Clause" 1239 | ], 1240 | "authors": [ 1241 | { 1242 | "name": "Sebastian Bergmann", 1243 | "email": "sebastian@phpunit.de", 1244 | "role": "lead" 1245 | } 1246 | ], 1247 | "description": "Library that helps with managing the version number of Git-hosted PHP projects", 1248 | "homepage": "https://github.com/sebastianbergmann/version", 1249 | "time": "2016-10-03T07:35:21+00:00" 1250 | }, 1251 | { 1252 | "name": "symfony/yaml", 1253 | "version": "v3.2.8", 1254 | "source": { 1255 | "type": "git", 1256 | "url": "https://github.com/symfony/yaml.git", 1257 | "reference": "acec26fcf7f3031e094e910b94b002fa53d4e4d6" 1258 | }, 1259 | "dist": { 1260 | "type": "zip", 1261 | "url": "https://api.github.com/repos/symfony/yaml/zipball/acec26fcf7f3031e094e910b94b002fa53d4e4d6", 1262 | "reference": "acec26fcf7f3031e094e910b94b002fa53d4e4d6", 1263 | "shasum": "" 1264 | }, 1265 | "require": { 1266 | "php": ">=5.5.9" 1267 | }, 1268 | "require-dev": { 1269 | "symfony/console": "~2.8|~3.0" 1270 | }, 1271 | "suggest": { 1272 | "symfony/console": "For validating YAML files using the lint command" 1273 | }, 1274 | "type": "library", 1275 | "extra": { 1276 | "branch-alias": { 1277 | "dev-master": "3.2-dev" 1278 | } 1279 | }, 1280 | "autoload": { 1281 | "psr-4": { 1282 | "Symfony\\Component\\Yaml\\": "" 1283 | }, 1284 | "exclude-from-classmap": [ 1285 | "/Tests/" 1286 | ] 1287 | }, 1288 | "notification-url": "https://packagist.org/downloads/", 1289 | "license": [ 1290 | "MIT" 1291 | ], 1292 | "authors": [ 1293 | { 1294 | "name": "Fabien Potencier", 1295 | "email": "fabien@symfony.com" 1296 | }, 1297 | { 1298 | "name": "Symfony Community", 1299 | "homepage": "https://symfony.com/contributors" 1300 | } 1301 | ], 1302 | "description": "Symfony Yaml Component", 1303 | "homepage": "https://symfony.com", 1304 | "time": "2017-05-01T14:55:58+00:00" 1305 | }, 1306 | { 1307 | "name": "webmozart/assert", 1308 | "version": "1.2.0", 1309 | "source": { 1310 | "type": "git", 1311 | "url": "https://github.com/webmozart/assert.git", 1312 | "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" 1313 | }, 1314 | "dist": { 1315 | "type": "zip", 1316 | "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", 1317 | "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", 1318 | "shasum": "" 1319 | }, 1320 | "require": { 1321 | "php": "^5.3.3 || ^7.0" 1322 | }, 1323 | "require-dev": { 1324 | "phpunit/phpunit": "^4.6", 1325 | "sebastian/version": "^1.0.1" 1326 | }, 1327 | "type": "library", 1328 | "extra": { 1329 | "branch-alias": { 1330 | "dev-master": "1.3-dev" 1331 | } 1332 | }, 1333 | "autoload": { 1334 | "psr-4": { 1335 | "Webmozart\\Assert\\": "src/" 1336 | } 1337 | }, 1338 | "notification-url": "https://packagist.org/downloads/", 1339 | "license": [ 1340 | "MIT" 1341 | ], 1342 | "authors": [ 1343 | { 1344 | "name": "Bernhard Schussek", 1345 | "email": "bschussek@gmail.com" 1346 | } 1347 | ], 1348 | "description": "Assertions to validate method input/output with nice error messages.", 1349 | "keywords": [ 1350 | "assert", 1351 | "check", 1352 | "validate" 1353 | ], 1354 | "time": "2016-11-23T20:04:58+00:00" 1355 | } 1356 | ], 1357 | "aliases": [], 1358 | "minimum-stability": "stable", 1359 | "stability-flags": [], 1360 | "prefer-stable": false, 1361 | "prefer-lowest": false, 1362 | "platform": { 1363 | "php": ">=5.3.0" 1364 | }, 1365 | "platform-dev": [] 1366 | } 1367 | -------------------------------------------------------------------------------- /config/currency_converter.php: -------------------------------------------------------------------------------- 1 | CI =& get_instance(); 25 | $this->CI->config->load('currency_converter', true); 26 | 27 | $this->currencyApiKey = $this->CI->config->item('currency_api_key', 'currency_converter'); 28 | 29 | $this->dbTable = $this->CI->config->item('currency_converter_db_table', 'currency_converter'); 30 | $this->rate = 0; 31 | } 32 | 33 | public function convert($fromCurrency, $toCurrency, $amount, $saveIntoDb = true, $hourDifference = 1) 34 | { 35 | if (null === $this->currencyApiKey) { 36 | throw new \Exception('Api Key missing'); 37 | } 38 | 39 | $this->fromCurrency = $fromCurrency; 40 | $this->toCurrency = $toCurrency; 41 | $this->amount = $amount; 42 | $this->hourDifference = $hourDifference; 43 | 44 | if ($this->fromCurrency != $this->toCurrency) { 45 | if ($this->fromCurrency == "PDS") { 46 | $this->fromCurrency = "GBP"; 47 | } 48 | 49 | if ($saveIntoDb == true) { 50 | return $this->saveIntoDatabase(); 51 | } 52 | 53 | $this->rate = $this->getRates(); 54 | $value = (double)$this->rate * (double)$amount; 55 | 56 | return number_format((double)$value, 2, '.', ''); 57 | } 58 | 59 | return number_format((double)$this->amount, 2, '.', ''); 60 | } 61 | 62 | private function saveIntoDatabase() 63 | { 64 | $this->checkIfExistTable(); 65 | 66 | $this->CI->db->select('*'); 67 | $this->CI->db->from($this->dbTable); 68 | $this->CI->db->where('from', $this->fromCurrency); 69 | $this->CI->db->where('to', $this->toCurrency); 70 | $query = $this->CI->db->get(); 71 | 72 | foreach ($query->result() as $row) { 73 | $lastUpdated = $row->modified; 74 | $now = date('Y-m-d H:i:s'); 75 | $dStart = new DateTime($now); 76 | $dEnd = new DateTime($lastUpdated); 77 | $diff = $dStart->diff($dEnd); 78 | 79 | if ($this->needToUpdateDatabase($diff, $row)) { 80 | $this->updateDatabase($row); 81 | } else { 82 | $this->rate = $row->rates; 83 | } 84 | } 85 | 86 | if (count($query->result()) <= 0) { 87 | $this->rate = $this->getRates(); 88 | 89 | $data = array( 90 | 'from' => $this->fromCurrency, 91 | 'to' => $this->toCurrency, 92 | 'rates' => $this->rate, 93 | 'created' => date('Y-m-d H:i:s'), 94 | 'modified' => date('Y-m-d H:i:s'), 95 | ); 96 | 97 | $this->CI->db->insert($this->dbTable, $data); 98 | } 99 | 100 | $value = (double)$this->rate * (double)$this->amount; 101 | 102 | return number_format((double)$value, 2, '.', ''); 103 | } 104 | 105 | private function updateDatabase($row) 106 | { 107 | $this->rate = $this->getRates(); 108 | 109 | $data = array( 110 | 'from' => $this->fromCurrency, 111 | 'to' => $this->toCurrency, 112 | 'rates' => $this->rate, 113 | 'modified' => date('Y-m-d H:i:s'), 114 | ); 115 | 116 | $this->CI->db->where('id', $row->id); 117 | $this->CI->db->update($this->dbTable, $data); 118 | } 119 | 120 | private function needToUpdateDatabase($diff, $row) 121 | { 122 | if ( 123 | ((int)$diff->y >= 1) || 124 | ((int)$diff->m >= 1) || 125 | ((int)$diff->d >= 1) || 126 | ((int)$diff->h >= $this->hourDifference) || 127 | ((double)$row->rates == 0) 128 | ) { 129 | return true; 130 | } 131 | 132 | return false; 133 | } 134 | 135 | private function getRates() 136 | { 137 | $url = 'https://free.currencyconverterapi.com/api/v5/convert?q=' . $this->fromCurrency . '_' . $this->toCurrency . '&compact=ultra&apiKey=' . $this->currencyApiKey; 138 | $handle = @fopen($url, 'r'); 139 | 140 | if ($handle) { 141 | $result = fgets($handle, 4096); 142 | fclose($handle); 143 | } 144 | 145 | if (isset($result)) { 146 | $conversion = json_decode($result, true); 147 | if (isset($conversion[$this->fromCurrency . '_' . $this->toCurrency])) { 148 | return $conversion[$this->fromCurrency . '_' . $this->toCurrency]; 149 | } 150 | } 151 | 152 | return $this->rate = 0; 153 | } 154 | 155 | private function checkIfExistTable() 156 | { 157 | if ($this->CI->db->table_exists($this->dbTable)) { 158 | return (true); 159 | } else { 160 | $this->CI->load->dbforge(); 161 | $this->CI->dbforge->add_field(array( 162 | 'id' => array( 163 | 'type' => 'INT', 164 | 'constraint' => 11, 165 | 'unsigned' => true, 166 | 'auto_increment' => true 167 | ), 168 | 'from' => array( 169 | 'type' => 'VARCHAR', 170 | 'constraint' => '5', 171 | 'null' => false 172 | ), 173 | 'to' => array( 174 | 'type' => 'VARCHAR', 175 | 'constraint' => '5', 176 | 'null' => false 177 | ), 178 | 'rates' => array( 179 | 'type' => 'VARCHAR', 180 | 'constraint' => '10', 181 | 'null' => false 182 | ), 183 | 'created' => array( 184 | 'type' => 'DATETIME' 185 | ), 186 | 'modified' => array( 187 | 'type' => 'DATETIME' 188 | ) 189 | )); 190 | 191 | $this->CI->dbforge->add_key('id', true); 192 | $this->CI->dbforge->create_table($this->dbTable, true); 193 | } 194 | } 195 | 196 | public function getCurrencyTable() 197 | { 198 | return $this->dbTable; 199 | } 200 | 201 | public function setApiKey($apiKey) 202 | { 203 | $this->currencyApiKey = $apiKey; 204 | } 205 | } 206 | -------------------------------------------------------------------------------- /models/example_model.php: -------------------------------------------------------------------------------- 1 | CurrencyConverter = new CurrencyConverter(); 9 | } 10 | 11 | public function convert(){ 12 | $amount = '2100,00'; 13 | $result = $this->CurrencyConverter->convert('GBP', 'EUR', $amount, 0, 1); 14 | 15 | return($result); 16 | } 17 | } 18 | ?> 19 | -------------------------------------------------------------------------------- /phpunit.php: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | ./tests 15 | 16 | 17 | 18 | 19 | 20 | ./vendor/codeigniter/framework/application/libraries/ 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /tests/CurrencyConverterTest.php: -------------------------------------------------------------------------------- 1 | load->library('currencyConverter'); 12 | $CI->load->database(); 13 | } 14 | 15 | public function testConvertWithoutSaveIntoDatabase() 16 | { 17 | $saveIntoDatabase = false; 18 | $hourDifference = 1; 19 | 20 | $this->currencyConverter = new CurrencyConverter(); 21 | $result = $this->currencyConverter->convert('GBP', 'EUR', '2000.00', $saveIntoDatabase, $hourDifference); 22 | 23 | $this->assertNotEmpty($result); 24 | 25 | $dbTable = $this->currencyConverter->getCurrencyTable(); 26 | 27 | $CI =& get_instance(); 28 | 29 | $this->assertFalse($CI->db->table_exists($dbTable)); 30 | } 31 | 32 | public function testConvertPds() 33 | { 34 | $saveIntoDatabase = false; 35 | $hourDifference = 1; 36 | 37 | $this->currencyConverter = new CurrencyConverter(); 38 | $result = $this->currencyConverter->convert('PDS', 'EUR', '2000.00', $saveIntoDatabase, $hourDifference); 39 | 40 | $this->assertNotEmpty($result); 41 | } 42 | 43 | public function testConvertSameCurrency() 44 | { 45 | $saveIntoDatabase = false; 46 | $hourDifference = 1; 47 | 48 | $this->currencyConverter = new CurrencyConverter(); 49 | $result = $this->currencyConverter->convert('EUR', 'EUR', '2000.00', $saveIntoDatabase, $hourDifference); 50 | 51 | $this->assertEquals($result, '2000.00'); 52 | } 53 | 54 | public function testConvertSaveIntoDatabase() 55 | { 56 | $saveIntoDatabase = true; 57 | $hourDifference = 1; 58 | 59 | $this->currencyConverter = new CurrencyConverter(); 60 | $result = $this->currencyConverter->convert('GBP', 'EUR', '2000.00', $saveIntoDatabase, $hourDifference); 61 | 62 | $this->assertNotEmpty($result); 63 | 64 | $dbTable = $this->currencyConverter->getCurrencyTable(); 65 | 66 | $CI =& get_instance(); 67 | $CI->db->select('*'); 68 | $CI->db->from($dbTable); 69 | $query = $CI->db->get(); 70 | 71 | $this->assertCount(1, $query->result()); 72 | } 73 | 74 | public function testNeedToUpdateDatabase() 75 | { 76 | $saveIntoDatabase = true; 77 | $hourDifference = -1; 78 | 79 | $this->currencyConverter = new CurrencyConverter(); 80 | $result = $this->currencyConverter->convert('GBP', 'EUR', '2000.00', $saveIntoDatabase, $hourDifference); 81 | 82 | $this->assertNotEmpty($result); 83 | 84 | $dbTable = $this->currencyConverter->getCurrencyTable(); 85 | 86 | $CI =& get_instance(); 87 | $CI->db->select('*'); 88 | $CI->db->from($dbTable); 89 | $query = $CI->db->get(); 90 | 91 | $this->assertCount(1, $query->result()); 92 | } 93 | 94 | public function testNotNeedToUpdateDatabase() 95 | { 96 | $saveIntoDatabase = true; 97 | $hourDifference = 100; 98 | 99 | $this->currencyConverter = new CurrencyConverter(); 100 | $result = $this->currencyConverter->convert('GBP', 'EUR', '2000.00', $saveIntoDatabase, $hourDifference); 101 | 102 | $this->assertNotEmpty($result); 103 | 104 | $dbTable = $this->currencyConverter->getCurrencyTable(); 105 | 106 | $CI =& get_instance(); 107 | $CI->db->select('*'); 108 | $CI->db->from($dbTable); 109 | $query = $CI->db->get(); 110 | 111 | $this->assertCount(1, $query->result()); 112 | } 113 | 114 | public function testNotExistingCurrency() 115 | { 116 | $saveIntoDatabase = true; 117 | $hourDifference = 100; 118 | 119 | $this->currencyConverter = new CurrencyConverter(); 120 | $result = $this->currencyConverter->convert('NOTEXISTS', 'EUR', '2000.00', $saveIntoDatabase, $hourDifference); 121 | 122 | $this->assertEquals(0, $result); 123 | } 124 | 125 | /** 126 | * @expectedException Exception 127 | */ 128 | public function testThrowExceptionIfApiKeyIsNotSet() 129 | { 130 | $saveIntoDatabase = false; 131 | $hourDifference = 1; 132 | 133 | $this->currencyConverter = new CurrencyConverter(); 134 | $this->currencyConverter->setApiKey(null); 135 | $this->currencyConverter->convert('EUR', 'EUR', '2000.00', $saveIntoDatabase, $hourDifference); 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /tests/currency_converter.php: -------------------------------------------------------------------------------- 1 | '', 9 | 'hostname' => 'sqlite:'.APPPATH.'config/sqlite-database.db', 10 | 'username' => '', 11 | 'password' => '', 12 | 'database' => '', 13 | 'dbdriver' => 'pdo', 14 | 'dbprefix' => '', 15 | 'pconnect' => true, 16 | 'db_debug' => true, 17 | 'cache_on' => false, 18 | 'cachedir' => '', 19 | 'char_set' => 'utf8', 20 | 'dbcollat' => 'utf8_general_ci', 21 | 'swap_pre' => '', 22 | 'encrypt' => false, 23 | 'compress' => false, 24 | 'stricton' => false, 25 | 'failover' => array(), 26 | 'save_queries' => true, 27 | 'autoinit' => true 28 | ); 29 | -------------------------------------------------------------------------------- /version.md: -------------------------------------------------------------------------------- 1 | 1.3.1 --------------------------------------------------------------------------------