From f86dfc759641af89de2d86cdce4b69030b1a6611 Mon Sep 17 00:00:00 2001 From: E Demirtas Date: Sat, 17 Apr 2021 18:22:50 +0100 Subject: [PATCH] Major bug fixes and improvements (#11) * Github actions (#9) Removed PHPLint Removed CircleCI config Added GitHub actions with multiple PHP version build check Added namespace for Tests, at the moment the tests are with the same namespace as the source. * Namespace fix (#10) - Replaced namespaces and folder structure for the entire package. - Removed direct composer autoload from files. (no idea why autoloader was directly loaded) * added test for mappers and fix for misspelt lastUpdateTimestam to lastUpdateTimestamp * updated namespaces on README.md * spelling mistake fix on autoload * clean up * phpcs clean up * phpcs PSR12 clean up * code clean up * fix for mapping issue * added phpcs and style clean up * fixed market holiday url and readme doc * upgraded guzzle to 7.2 * added minimum php requirement to v7.2.5 * depricated public properties will be removed in next major version * seperated test concerns * moved rest to Rest * Delete tests/rest directory * added circlici back * removed composer.lock * Update php.yml Updated branch * Update php.yml Added master branch to run configuration --- .circleci/config.yml | 1 - .github/workflows/php.yml | 46 + .phplint.yml | 7 - README.md | 16 +- composer.json | 25 +- composer.lock | 3182 ----------------- phpunit.xml | 5 +- src/Polygon.php | 23 - src/PolygonIO.php | 60 + src/Rest/Common/Mappers.php | 176 + src/Rest/Crypto/Aggregates.php | 48 + src/Rest/Crypto/Crypto.php | 189 + src/Rest/Crypto/CryptoExchanges.php | 24 + src/Rest/Crypto/DailyOpenClose.php | 47 + src/Rest/Crypto/GroupedDaily.php | 47 + src/Rest/Crypto/HistoricCryptoTrade.php | 50 + src/Rest/Crypto/LastTradeForCryptoPair.php | 21 + src/Rest/Crypto/PreviousClose.php | 45 + src/Rest/Crypto/SnapshotAllTickers.php | 42 + src/Rest/Crypto/SnapshotGainersLosers.php | 44 + src/Rest/Crypto/SnapshotSingleTicker.php | 39 + .../Crypto/SnapshotSingleTickerFullBook.php | 48 + src/Rest/Forex/Aggregates.php | 48 + src/Rest/Forex/Forex.php | 139 + src/Rest/Forex/GroupedDaily.php | 47 + src/Rest/Forex/HistoricForexTick.php | 32 + src/Rest/Forex/LastQuoteForCurrencyPair.php | 26 + src/Rest/Forex/PreviousClose.php | 45 + src/Rest/Forex/RealTimeCurrencyConversion.php | 32 + src/Rest/Forex/SnapshotAllTickers.php | 41 + src/Rest/Forex/SnapshotGainersLosers.php | 43 + src/Rest/Reference/Locales.php | 25 + src/Rest/Reference/MarketHolidays.php | 25 + src/Rest/Reference/MarketStatus.php | 25 + src/Rest/Reference/Markets.php | 25 + src/Rest/Reference/Reference.php | 192 + src/Rest/Reference/StockDividends.php | 25 + src/Rest/Reference/StockFinancials.php | 30 + src/Rest/Reference/StockSplits.php | 25 + src/Rest/Reference/TickerDetails.php | 42 + src/Rest/Reference/TickerNews.php | 31 + src/Rest/Reference/TickerTypes.php | 25 + .../reference => Rest/Reference}/Tickers.php | 19 +- src/Rest/Rest.php | 89 + src/Rest/RestResource.php | 91 + src/Rest/Stocks/Aggregates.php | 49 + src/Rest/Stocks/ConditionMappings.php | 24 + src/Rest/Stocks/DailyOpenClose.php | 26 + src/Rest/Stocks/Exchanges.php | 25 + src/Rest/Stocks/GroupedDaily.php | 47 + src/Rest/Stocks/HistoricQuotes.php | 49 + src/Rest/Stocks/HistoricQuotesV2.php | 69 + src/Rest/Stocks/HistoricTrades.php | 50 + src/Rest/Stocks/HistoricTradesV2.php | 63 + src/Rest/Stocks/LastQuoteForSymbol.php | 25 + src/Rest/Stocks/LastTradeForSymbol.php | 25 + src/Rest/Stocks/PreviousClose.php | 45 + src/Rest/Stocks/SnapshotAllTickers.php | 41 + src/Rest/Stocks/SnapshotGainersLosers.php | 44 + src/Rest/Stocks/SnapshotSingleTicker.php | 38 + src/Rest/Stocks/Stocks.php | 247 ++ src/Websockets/WebsocketResource.php | 65 + src/Websockets/Websockets.php | 67 + src/rest/Rest.php | 26 - src/rest/RestResource.php | 50 - src/rest/common/Mappers.php | 89 - src/rest/crypto/Aggregates.php | 19 - src/rest/crypto/Crypto.php | 31 - src/rest/crypto/CryptoExchanges.php | 11 - src/rest/crypto/DailyOpenClose.php | 22 - src/rest/crypto/GroupedDaily.php | 19 - src/rest/crypto/HistoricCryptoTrade.php | 23 - src/rest/crypto/LastTradeForCryptoPair.php | 10 - src/rest/crypto/PreviousClose.php | 19 - src/rest/crypto/SnapshotAllTickers.php | 19 - src/rest/crypto/SnapshotGainersLosers.php | 19 - src/rest/crypto/SnapshotSingleTicker.php | 17 - .../crypto/SnapshotSingleTickerFullBook.php | 26 - src/rest/forex/Aggregates.php | 19 - src/rest/forex/Forex.php | 25 - src/rest/forex/GroupedDaily.php | 19 - src/rest/forex/HistoricForexTick.php | 14 - src/rest/forex/LastQuoteForCurrencyPair.php | 10 - src/rest/forex/PreviousClose.php | 19 - src/rest/forex/RealTimeCurrencyConversion.php | 15 - src/rest/forex/SnapshotAllTickers.php | 19 - src/rest/forex/SnapshotGainersLosers.php | 19 - src/rest/reference/Locales.php | 16 - src/rest/reference/MarketHolidays.php | 16 - src/rest/reference/MarketStatus.php | 16 - src/rest/reference/Markets.php | 16 - src/rest/reference/Reference.php | 39 - src/rest/reference/StockDividends.php | 18 - src/rest/reference/StockFinancials.php | 19 - src/rest/reference/StockSplits.php | 18 - src/rest/reference/TickerDetails.php | 24 - src/rest/reference/TickerNews.php | 24 - src/rest/reference/TickerTypes.php | 16 - src/rest/stocks/Aggregates.php | 19 - src/rest/stocks/ConditionMappings.php | 10 - src/rest/stocks/DailyOpenClose.php | 10 - src/rest/stocks/Exchanges.php | 12 - src/rest/stocks/GroupedDaily.php | 19 - src/rest/stocks/HistoricQuotes.php | 29 - src/rest/stocks/HistoricQuotesV2.php | 37 - src/rest/stocks/HistoricTrades.php | 29 - src/rest/stocks/HistoricTradesV2.php | 32 - src/rest/stocks/LastQuoteForSymbol.php | 10 - src/rest/stocks/LastTradeForSymbol.php | 10 - src/rest/stocks/PreviousClose.php | 19 - src/rest/stocks/SnapshotAllTickers.php | 19 - src/rest/stocks/SnapshotGainersLosers.php | 19 - src/rest/stocks/SnapshotSingleTicker.php | 17 - src/rest/stocks/Stocks.php | 41 - src/websocket/WebsocketResource.php | 32 - src/websocket/Websockets.php | 15 - tests/Helpers/MocksHttp.php | 35 + tests/Rest/Common/MappersTest.php | 426 +++ tests/Rest/Crypto/AggregatesTest.php | 28 + tests/Rest/Crypto/CryptoExchangesTest.php | 23 + tests/Rest/Crypto/CryptoTest.php | 91 + tests/Rest/Crypto/DailyOpenCloseTest.php | 23 + tests/Rest/Crypto/GroupedDailyTest.php | 27 + tests/Rest/Crypto/HistoricCryptoTradeTest.php | 27 + .../Crypto/LastTradeForCryptoPairTest.php | 23 + tests/Rest/Crypto/PreviousCloseTest.php | 27 + tests/Rest/Crypto/SnapshotAllTickersTest.php | 27 + .../Rest/Crypto/SnapshotGainersLosersTest.php | 28 + .../SnapshotSingleTickerFullBookTest.php | 31 + .../Rest/Crypto/SnapshotSingleTickerTest.php | 57 + tests/Rest/Forex/AggregatesTest.php | 27 + tests/Rest/Forex/ForexTest.php | 74 + tests/Rest/Forex/GroupedDailyTest.php | 27 + tests/Rest/Forex/HistoricForexTickTest.php | 23 + .../Forex/LastQuoteForCurrencyPairTest.php | 23 + tests/Rest/Forex/PreviousCloseTest.php | 27 + .../Forex/RealTimeCurrencyConversionTest.php | 23 + tests/Rest/Forex/SnapshotAllTickersTest.php | 27 + .../Rest/Forex/SnapshotGainersLosersTest.php | 27 + tests/Rest/Reference/LocalesTest.php | 23 + tests/Rest/Reference/MarketHolidaysTest.php | 23 + tests/Rest/Reference/MarketStatusTest.php | 23 + tests/Rest/Reference/MarketsTest.php | 23 + tests/Rest/Reference/ReferenceTest.php | 88 + tests/Rest/Reference/StockDividendsTest.php | 23 + tests/Rest/Reference/StockFinancialsTest.php | 23 + tests/Rest/Reference/StockSplitsTest.php | 23 + tests/Rest/Reference/TickerDetailsTest.php | 30 + tests/Rest/Reference/TickerNewsTest.php | 22 + tests/Rest/Reference/TickerTypesTest.php | 23 + tests/Rest/Reference/TickersTest.php | 23 + tests/Rest/Stocks/AggregatesTest.php | 27 + tests/Rest/Stocks/ConditionMappingsTest.php | 24 + tests/Rest/Stocks/DailyOpenCloseTest.php | 23 + tests/Rest/Stocks/ExchangesTest.php | 23 + tests/Rest/Stocks/GroupedDailyTest.php | 27 + tests/Rest/Stocks/HistoricQuotesTest.php | 27 + tests/Rest/Stocks/HistoricQuotesV2Test.php | 27 + tests/Rest/Stocks/HistoricTradesTest.php | 29 + tests/Rest/Stocks/HistoricTradesV2Test.php | 27 + tests/Rest/Stocks/LastQuoteForSymbolTest.php | 23 + tests/Rest/Stocks/LastTradeForSymbolTest.php | 23 + tests/Rest/Stocks/PreviousCloseTest.php | 27 + tests/Rest/Stocks/SnapshotAllTickersTest.php | 27 + .../Rest/Stocks/SnapshotGainersLosersTest.php | 26 + .../Rest/Stocks/SnapshotSingleTickerTest.php | 67 + tests/Rest/Stocks/StocksTest.php | 116 + tests/rest/CryptoTest.php | 214 -- tests/rest/ForexTest.php | 140 - tests/rest/ReferenceTest.php | 182 - tests/rest/StocksTest.php | 293 -- 171 files changed, 5112 insertions(+), 5224 deletions(-) create mode 100644 .github/workflows/php.yml delete mode 100644 .phplint.yml delete mode 100644 composer.lock delete mode 100644 src/Polygon.php create mode 100644 src/PolygonIO.php create mode 100644 src/Rest/Common/Mappers.php create mode 100644 src/Rest/Crypto/Aggregates.php create mode 100644 src/Rest/Crypto/Crypto.php create mode 100644 src/Rest/Crypto/CryptoExchanges.php create mode 100644 src/Rest/Crypto/DailyOpenClose.php create mode 100644 src/Rest/Crypto/GroupedDaily.php create mode 100644 src/Rest/Crypto/HistoricCryptoTrade.php create mode 100644 src/Rest/Crypto/LastTradeForCryptoPair.php create mode 100644 src/Rest/Crypto/PreviousClose.php create mode 100644 src/Rest/Crypto/SnapshotAllTickers.php create mode 100644 src/Rest/Crypto/SnapshotGainersLosers.php create mode 100644 src/Rest/Crypto/SnapshotSingleTicker.php create mode 100644 src/Rest/Crypto/SnapshotSingleTickerFullBook.php create mode 100644 src/Rest/Forex/Aggregates.php create mode 100644 src/Rest/Forex/Forex.php create mode 100644 src/Rest/Forex/GroupedDaily.php create mode 100644 src/Rest/Forex/HistoricForexTick.php create mode 100644 src/Rest/Forex/LastQuoteForCurrencyPair.php create mode 100644 src/Rest/Forex/PreviousClose.php create mode 100644 src/Rest/Forex/RealTimeCurrencyConversion.php create mode 100644 src/Rest/Forex/SnapshotAllTickers.php create mode 100644 src/Rest/Forex/SnapshotGainersLosers.php create mode 100644 src/Rest/Reference/Locales.php create mode 100644 src/Rest/Reference/MarketHolidays.php create mode 100644 src/Rest/Reference/MarketStatus.php create mode 100644 src/Rest/Reference/Markets.php create mode 100644 src/Rest/Reference/Reference.php create mode 100644 src/Rest/Reference/StockDividends.php create mode 100644 src/Rest/Reference/StockFinancials.php create mode 100644 src/Rest/Reference/StockSplits.php create mode 100644 src/Rest/Reference/TickerDetails.php create mode 100644 src/Rest/Reference/TickerNews.php create mode 100644 src/Rest/Reference/TickerTypes.php rename src/{rest/reference => Rest/Reference}/Tickers.php (56%) create mode 100644 src/Rest/Rest.php create mode 100644 src/Rest/RestResource.php create mode 100644 src/Rest/Stocks/Aggregates.php create mode 100644 src/Rest/Stocks/ConditionMappings.php create mode 100644 src/Rest/Stocks/DailyOpenClose.php create mode 100644 src/Rest/Stocks/Exchanges.php create mode 100644 src/Rest/Stocks/GroupedDaily.php create mode 100644 src/Rest/Stocks/HistoricQuotes.php create mode 100644 src/Rest/Stocks/HistoricQuotesV2.php create mode 100644 src/Rest/Stocks/HistoricTrades.php create mode 100644 src/Rest/Stocks/HistoricTradesV2.php create mode 100644 src/Rest/Stocks/LastQuoteForSymbol.php create mode 100644 src/Rest/Stocks/LastTradeForSymbol.php create mode 100644 src/Rest/Stocks/PreviousClose.php create mode 100644 src/Rest/Stocks/SnapshotAllTickers.php create mode 100644 src/Rest/Stocks/SnapshotGainersLosers.php create mode 100644 src/Rest/Stocks/SnapshotSingleTicker.php create mode 100644 src/Rest/Stocks/Stocks.php create mode 100644 src/Websockets/WebsocketResource.php create mode 100644 src/Websockets/Websockets.php delete mode 100644 src/rest/Rest.php delete mode 100644 src/rest/RestResource.php delete mode 100644 src/rest/common/Mappers.php delete mode 100644 src/rest/crypto/Aggregates.php delete mode 100644 src/rest/crypto/Crypto.php delete mode 100644 src/rest/crypto/CryptoExchanges.php delete mode 100644 src/rest/crypto/DailyOpenClose.php delete mode 100644 src/rest/crypto/GroupedDaily.php delete mode 100644 src/rest/crypto/HistoricCryptoTrade.php delete mode 100644 src/rest/crypto/LastTradeForCryptoPair.php delete mode 100644 src/rest/crypto/PreviousClose.php delete mode 100644 src/rest/crypto/SnapshotAllTickers.php delete mode 100644 src/rest/crypto/SnapshotGainersLosers.php delete mode 100644 src/rest/crypto/SnapshotSingleTicker.php delete mode 100644 src/rest/crypto/SnapshotSingleTickerFullBook.php delete mode 100644 src/rest/forex/Aggregates.php delete mode 100644 src/rest/forex/Forex.php delete mode 100644 src/rest/forex/GroupedDaily.php delete mode 100644 src/rest/forex/HistoricForexTick.php delete mode 100644 src/rest/forex/LastQuoteForCurrencyPair.php delete mode 100644 src/rest/forex/PreviousClose.php delete mode 100644 src/rest/forex/RealTimeCurrencyConversion.php delete mode 100644 src/rest/forex/SnapshotAllTickers.php delete mode 100644 src/rest/forex/SnapshotGainersLosers.php delete mode 100644 src/rest/reference/Locales.php delete mode 100644 src/rest/reference/MarketHolidays.php delete mode 100644 src/rest/reference/MarketStatus.php delete mode 100644 src/rest/reference/Markets.php delete mode 100644 src/rest/reference/Reference.php delete mode 100644 src/rest/reference/StockDividends.php delete mode 100644 src/rest/reference/StockFinancials.php delete mode 100644 src/rest/reference/StockSplits.php delete mode 100644 src/rest/reference/TickerDetails.php delete mode 100644 src/rest/reference/TickerNews.php delete mode 100644 src/rest/reference/TickerTypes.php delete mode 100644 src/rest/stocks/Aggregates.php delete mode 100644 src/rest/stocks/ConditionMappings.php delete mode 100644 src/rest/stocks/DailyOpenClose.php delete mode 100644 src/rest/stocks/Exchanges.php delete mode 100644 src/rest/stocks/GroupedDaily.php delete mode 100644 src/rest/stocks/HistoricQuotes.php delete mode 100644 src/rest/stocks/HistoricQuotesV2.php delete mode 100644 src/rest/stocks/HistoricTrades.php delete mode 100644 src/rest/stocks/HistoricTradesV2.php delete mode 100644 src/rest/stocks/LastQuoteForSymbol.php delete mode 100644 src/rest/stocks/LastTradeForSymbol.php delete mode 100644 src/rest/stocks/PreviousClose.php delete mode 100644 src/rest/stocks/SnapshotAllTickers.php delete mode 100644 src/rest/stocks/SnapshotGainersLosers.php delete mode 100644 src/rest/stocks/SnapshotSingleTicker.php delete mode 100644 src/rest/stocks/Stocks.php delete mode 100644 src/websocket/WebsocketResource.php delete mode 100644 src/websocket/Websockets.php create mode 100644 tests/Helpers/MocksHttp.php create mode 100644 tests/Rest/Common/MappersTest.php create mode 100644 tests/Rest/Crypto/AggregatesTest.php create mode 100644 tests/Rest/Crypto/CryptoExchangesTest.php create mode 100644 tests/Rest/Crypto/CryptoTest.php create mode 100644 tests/Rest/Crypto/DailyOpenCloseTest.php create mode 100644 tests/Rest/Crypto/GroupedDailyTest.php create mode 100644 tests/Rest/Crypto/HistoricCryptoTradeTest.php create mode 100644 tests/Rest/Crypto/LastTradeForCryptoPairTest.php create mode 100644 tests/Rest/Crypto/PreviousCloseTest.php create mode 100644 tests/Rest/Crypto/SnapshotAllTickersTest.php create mode 100644 tests/Rest/Crypto/SnapshotGainersLosersTest.php create mode 100644 tests/Rest/Crypto/SnapshotSingleTickerFullBookTest.php create mode 100644 tests/Rest/Crypto/SnapshotSingleTickerTest.php create mode 100644 tests/Rest/Forex/AggregatesTest.php create mode 100644 tests/Rest/Forex/ForexTest.php create mode 100644 tests/Rest/Forex/GroupedDailyTest.php create mode 100644 tests/Rest/Forex/HistoricForexTickTest.php create mode 100644 tests/Rest/Forex/LastQuoteForCurrencyPairTest.php create mode 100644 tests/Rest/Forex/PreviousCloseTest.php create mode 100644 tests/Rest/Forex/RealTimeCurrencyConversionTest.php create mode 100644 tests/Rest/Forex/SnapshotAllTickersTest.php create mode 100644 tests/Rest/Forex/SnapshotGainersLosersTest.php create mode 100644 tests/Rest/Reference/LocalesTest.php create mode 100644 tests/Rest/Reference/MarketHolidaysTest.php create mode 100644 tests/Rest/Reference/MarketStatusTest.php create mode 100644 tests/Rest/Reference/MarketsTest.php create mode 100644 tests/Rest/Reference/ReferenceTest.php create mode 100644 tests/Rest/Reference/StockDividendsTest.php create mode 100644 tests/Rest/Reference/StockFinancialsTest.php create mode 100644 tests/Rest/Reference/StockSplitsTest.php create mode 100644 tests/Rest/Reference/TickerDetailsTest.php create mode 100644 tests/Rest/Reference/TickerNewsTest.php create mode 100644 tests/Rest/Reference/TickerTypesTest.php create mode 100644 tests/Rest/Reference/TickersTest.php create mode 100644 tests/Rest/Stocks/AggregatesTest.php create mode 100644 tests/Rest/Stocks/ConditionMappingsTest.php create mode 100644 tests/Rest/Stocks/DailyOpenCloseTest.php create mode 100644 tests/Rest/Stocks/ExchangesTest.php create mode 100644 tests/Rest/Stocks/GroupedDailyTest.php create mode 100644 tests/Rest/Stocks/HistoricQuotesTest.php create mode 100644 tests/Rest/Stocks/HistoricQuotesV2Test.php create mode 100644 tests/Rest/Stocks/HistoricTradesTest.php create mode 100644 tests/Rest/Stocks/HistoricTradesV2Test.php create mode 100644 tests/Rest/Stocks/LastQuoteForSymbolTest.php create mode 100644 tests/Rest/Stocks/LastTradeForSymbolTest.php create mode 100644 tests/Rest/Stocks/PreviousCloseTest.php create mode 100644 tests/Rest/Stocks/SnapshotAllTickersTest.php create mode 100644 tests/Rest/Stocks/SnapshotGainersLosersTest.php create mode 100644 tests/Rest/Stocks/SnapshotSingleTickerTest.php create mode 100644 tests/Rest/Stocks/StocksTest.php delete mode 100644 tests/rest/CryptoTest.php delete mode 100644 tests/rest/ForexTest.php delete mode 100644 tests/rest/ReferenceTest.php delete mode 100644 tests/rest/StocksTest.php diff --git a/.circleci/config.yml b/.circleci/config.yml index 37ad738..a0abc47 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,5 +17,4 @@ jobs: key: composer-v1-{{ checksum "composer.lock" }} paths: - vendor - - run: ./vendor/bin/phplint . - run: ./vendor/bin/phpunit diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..98cf336 --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,46 @@ +name: PHP Composer + +on: + push: + branches: [ develop, master ] + pull_request: + branches: [ develop, master] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + php-versions: ['7.2', '7.3', '7.4', '8.0'] + steps: + - uses: actions/checkout@v2 + + - name: Setup PHP ${{ matrix.php-versions }} with tools + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + tools: phan, phpunit + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v2 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + - name: Install dependencies + if: steps.composer-cache.outputs.cache-hit != 'true' + run: composer install --prefer-dist --no-progress --no-suggest +# +# - name: Run linter +# run: composer lint + + # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" + # Docs: https://getcomposer.org/doc/articles/scripts.md + + - name: Run test suite + run: composer test diff --git a/.phplint.yml b/.phplint.yml deleted file mode 100644 index eab594f..0000000 --- a/.phplint.yml +++ /dev/null @@ -1,7 +0,0 @@ -path: ./ -jobs: 10 -cache: build/phplint.cache -extensions: - - php -exclude: - - vendor \ No newline at end of file diff --git a/README.md b/README.md index 6227cba..d013cb9 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ composer require polygon-io/api ## [Rest API](https://polygon.io/docs/#getting-started) -The `\PolygonIO\rest\Rest` class export 4 modules: +The `\PolygonIO\Rest\Rest` class export 4 modules: - reference - stocks @@ -26,12 +26,12 @@ The `\PolygonIO\rest\Rest` class export 4 modules: ``` forex->realtimeCurrencyConverion->get('USD', 'EUR', 10)); +print_r($rest->forex->realTimeCurrencyConversion->get('USD', 'EUR', 10)); ``` @@ -42,7 +42,7 @@ You can only use one websocket client by php thread since the event loop is in a ``` websockets->forex( function($data) { // your handler function } -) +); ``` -## Developement +## Development ### prerequisite diff --git a/composer.json b/composer.json index e9c88cb..56534c9 100644 --- a/composer.json +++ b/composer.json @@ -7,19 +7,34 @@ { "name": "Julien Prugne", "email": "julien@webeleon.dev" + }, + { + "name": "Ersin Demirtas", + "email": "ed5@me.com" } ], "require": { - "guzzlehttp/guzzle": "^6.4", - "amphp/websocket-client": "^0.2.4" + "php":">=7.2.5", + "ext-json": "*", + "guzzlehttp/guzzle": "^7.2.0", + "amphp/websocket-client": "^0.2.4", + "psr/http-client": "^1.0" + }, + "require-dev": { + "phpunit/phpunit": "^8", + "squizlabs/php_codesniffer": "^3.5" }, "autoload": { "psr-4": { "PolygonIO\\": "src/" } }, - "require-dev": { - "overtrue/phplint": "^1.1", - "phpunit/phpunit": "^8" + "autoload-dev": { + "psr-4": { + "PolygonIO\\Tests\\": "tests/" + } + }, + "scripts": { + "test": "./vendor/bin/phpunit" } } diff --git a/composer.lock b/composer.lock deleted file mode 100644 index fc470f5..0000000 --- a/composer.lock +++ /dev/null @@ -1,3182 +0,0 @@ -{ - "_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#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "6bbd5d6dfbac32f9dbb920e546cd0a33", - "packages": [ - { - "name": "amphp/amp", - "version": "v2.3.2", - "source": { - "type": "git", - "url": "https://github.com/amphp/amp.git", - "reference": "9fa04aa6f87a8200fc0961de6bcc5465785c0c6f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/amphp/amp/zipball/9fa04aa6f87a8200fc0961de6bcc5465785c0c6f", - "reference": "9fa04aa6f87a8200fc0961de6bcc5465785c0c6f", - "shasum": "" - }, - "require": { - "php": ">=7" - }, - "require-dev": { - "amphp/php-cs-fixer-config": "dev-master", - "amphp/phpunit-util": "^1", - "ext-json": "*", - "phpstan/phpstan": "^0.8.5", - "phpunit/phpunit": "^6.0.9 | ^7", - "react/promise": "^2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Amp\\": "lib" - }, - "files": [ - "lib/functions.php", - "lib/Internal/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Daniel Lowrey", - "email": "rdlowrey@php.net" - }, - { - "name": "Aaron Piotrowski", - "email": "aaron@trowski.com" - }, - { - "name": "Bob Weinand", - "email": "bobwei9@hotmail.com" - }, - { - "name": "Niklas Keller", - "email": "me@kelunik.com" - } - ], - "description": "A non-blocking concurrency framework for PHP applications.", - "homepage": "http://amphp.org/amp", - "keywords": [ - "async", - "asynchronous", - "awaitable", - "concurrency", - "event", - "event-loop", - "future", - "non-blocking", - "promise" - ], - "time": "2019-10-26T14:31:57+00:00" - }, - { - "name": "amphp/byte-stream", - "version": "v1.7.1", - "source": { - "type": "git", - "url": "https://github.com/amphp/byte-stream.git", - "reference": "9d8205686a004948475dc43f8a88d2fa5e75a113" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/amphp/byte-stream/zipball/9d8205686a004948475dc43f8a88d2fa5e75a113", - "reference": "9d8205686a004948475dc43f8a88d2fa5e75a113", - "shasum": "" - }, - "require": { - "amphp/amp": "^2" - }, - "require-dev": { - "amphp/php-cs-fixer-config": "dev-master", - "amphp/phpunit-util": "^1", - "friendsofphp/php-cs-fixer": "^2.3", - "infection/infection": "^0.9.3", - "phpunit/phpunit": "^6" - }, - "type": "library", - "autoload": { - "psr-4": { - "Amp\\ByteStream\\": "lib" - }, - "files": [ - "lib/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Aaron Piotrowski", - "email": "aaron@trowski.com" - }, - { - "name": "Niklas Keller", - "email": "me@kelunik.com" - } - ], - "description": "A stream abstraction to make working with non-blocking I/O simple.", - "homepage": "http://amphp.org/byte-stream", - "keywords": [ - "amp", - "amphp", - "async", - "io", - "non-blocking", - "stream" - ], - "time": "2019-10-27T14:33:41+00:00" - }, - { - "name": "amphp/cache", - "version": "v1.2.1", - "source": { - "type": "git", - "url": "https://github.com/amphp/cache.git", - "reference": "884c102a84fdda3eac71746878d55312319550f6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/amphp/cache/zipball/884c102a84fdda3eac71746878d55312319550f6", - "reference": "884c102a84fdda3eac71746878d55312319550f6", - "shasum": "" - }, - "require": { - "amphp/amp": "^2" - }, - "require-dev": { - "amphp/php-cs-fixer-config": "dev-master", - "amphp/phpunit-util": "^1", - "phpunit/phpunit": "^6 | ^7 | ^8" - }, - "type": "library", - "autoload": { - "psr-4": { - "Amp\\Cache\\": "lib" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Niklas Keller", - "email": "me@kelunik.com" - }, - { - "name": "Daniel Lowrey", - "email": "rdlowrey@php.net" - } - ], - "description": "A promise-aware caching API for Amp.", - "homepage": "https://github.com/amphp/cache", - "time": "2019-09-21T08:52:12+00:00" - }, - { - "name": "amphp/dns", - "version": "v0.9.15", - "source": { - "type": "git", - "url": "https://github.com/amphp/dns.git", - "reference": "2a3e7376f42b289230c0921aceaec5bbf253299d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/amphp/dns/zipball/2a3e7376f42b289230c0921aceaec5bbf253299d", - "reference": "2a3e7376f42b289230c0921aceaec5bbf253299d", - "shasum": "" - }, - "require": { - "amphp/amp": "^2", - "amphp/byte-stream": "^1.1", - "amphp/cache": "^1.2", - "amphp/parser": "^1", - "amphp/windows-registry": "^0.3", - "daverandom/libdns": "^2.0.1", - "ext-filter": "*", - "php": ">=7.0" - }, - "require-dev": { - "amphp/php-cs-fixer-config": "dev-master", - "amphp/phpunit-util": "^1", - "phpunit/phpunit": "^6" - }, - "type": "library", - "autoload": { - "psr-4": { - "Amp\\Dns\\": "lib" - }, - "files": [ - "lib/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bob Weinand", - "email": "bobwei9@hotmail.com" - }, - { - "name": "Niklas Keller", - "email": "me@kelunik.com" - }, - { - "name": "Daniel Lowrey", - "email": "rdlowrey@php.net" - }, - { - "name": "Chris Wright", - "email": "addr@daverandom.com" - }, - { - "name": "Aaron Piotrowski", - "email": "aaron@trowski.com" - } - ], - "description": "Async DNS resolution for Amp.", - "homepage": "https://github.com/amphp/dns", - "keywords": [ - "amp", - "amphp", - "async", - "client", - "dns", - "resolve" - ], - "time": "2019-07-08T20:58:50+00:00" - }, - { - "name": "amphp/http", - "version": "v1.5.0", - "source": { - "type": "git", - "url": "https://github.com/amphp/http.git", - "reference": "9bc6ad5b2d92afb959068a65a21ce0409c7db67e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/amphp/http/zipball/9bc6ad5b2d92afb959068a65a21ce0409c7db67e", - "reference": "9bc6ad5b2d92afb959068a65a21ce0409c7db67e", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "require-dev": { - "amphp/php-cs-fixer-config": "dev-master", - "phpunit/phpunit": "^6.5" - }, - "type": "library", - "autoload": { - "psr-4": { - "Amp\\Http\\": "src" - }, - "files": [ - "src/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Niklas Keller", - "email": "me@kelunik.com" - } - ], - "description": "Basic HTTP primitives which can be shared by servers and clients.", - "time": "2019-11-04T21:24:40+00:00" - }, - { - "name": "amphp/parser", - "version": "v1.0.0", - "source": { - "type": "git", - "url": "https://github.com/amphp/parser.git", - "reference": "f83e68f03d5b8e8e0365b8792985a7f341c57ae1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/amphp/parser/zipball/f83e68f03d5b8e8e0365b8792985a7f341c57ae1", - "reference": "f83e68f03d5b8e8e0365b8792985a7f341c57ae1", - "shasum": "" - }, - "require": { - "php": ">=7" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.3", - "phpunit/phpunit": "^6" - }, - "type": "library", - "autoload": { - "psr-4": { - "Amp\\Parser\\": "lib" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Niklas Keller", - "email": "me@kelunik.com" - }, - { - "name": "Aaron Piotrowski", - "email": "aaron@trowski.com" - } - ], - "description": "A generator parser to make streaming parsers simple.", - "homepage": "https://github.com/amphp/parser", - "keywords": [ - "async", - "non-blocking", - "parser", - "stream" - ], - "time": "2017-06-06T05:29:10+00:00" - }, - { - "name": "amphp/process", - "version": "v1.1.0", - "source": { - "type": "git", - "url": "https://github.com/amphp/process.git", - "reference": "355b1e561b01c16ab3d78fada1ad47ccc96df70e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/amphp/process/zipball/355b1e561b01c16ab3d78fada1ad47ccc96df70e", - "reference": "355b1e561b01c16ab3d78fada1ad47ccc96df70e", - "shasum": "" - }, - "require": { - "amphp/amp": "^2", - "amphp/byte-stream": "^1.4", - "php": ">=7" - }, - "require-dev": { - "amphp/php-cs-fixer-config": "dev-master", - "amphp/phpunit-util": "^1", - "phpunit/phpunit": "^6" - }, - "type": "library", - "autoload": { - "psr-4": { - "Amp\\Process\\": "lib" - }, - "files": [ - "lib/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bob Weinand", - "email": "bobwei9@hotmail.com" - }, - { - "name": "Niklas Keller", - "email": "me@kelunik.com" - }, - { - "name": "Aaron Piotrowski", - "email": "aaron@trowski.com" - } - ], - "description": "Asynchronous process manager.", - "homepage": "https://github.com/amphp/process", - "time": "2019-02-26T16:33:03+00:00" - }, - { - "name": "amphp/socket", - "version": "v0.10.13", - "source": { - "type": "git", - "url": "https://github.com/amphp/socket.git", - "reference": "d84f6e09675488a52fb6ff5e2d53ecc5d587667a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/amphp/socket/zipball/d84f6e09675488a52fb6ff5e2d53ecc5d587667a", - "reference": "d84f6e09675488a52fb6ff5e2d53ecc5d587667a", - "shasum": "" - }, - "require": { - "amphp/amp": "^2", - "amphp/byte-stream": "^1.1", - "amphp/dns": "^0.9", - "amphp/uri": "^0.1", - "php": ">=7.0" - }, - "require-dev": { - "amphp/phpunit-util": "^1", - "friendsofphp/php-cs-fixer": "^2.3", - "phpunit/phpunit": "^6" - }, - "type": "library", - "autoload": { - "psr-4": { - "Amp\\Socket\\": "src" - }, - "files": [ - "src/functions.php", - "src/Internal/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Daniel Lowrey", - "email": "rdlowrey@gmail.com" - }, - { - "name": "Aaron Piotrowski", - "email": "aaron@trowski.com" - }, - { - "name": "Niklas Keller", - "email": "me@kelunik.com" - } - ], - "description": "Async socket connection / server tools for Amp.", - "homepage": "https://github.com/amphp/socket", - "keywords": [ - "amp", - "async", - "encryption", - "non-blocking", - "sockets", - "tcp", - "tls" - ], - "time": "2019-11-05T22:34:12+00:00" - }, - { - "name": "amphp/uri", - "version": "v0.1.4", - "source": { - "type": "git", - "url": "https://github.com/amphp/uri.git", - "reference": "30065946d5c69f44c8a47bf8838244029984ff61" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/amphp/uri/zipball/30065946d5c69f44c8a47bf8838244029984ff61", - "reference": "30065946d5c69f44c8a47bf8838244029984ff61", - "shasum": "" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.3", - "phpunit/phpunit": "^6" - }, - "type": "library", - "autoload": { - "psr-4": { - "Amp\\Uri\\": "src" - }, - "files": [ - "src/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Niklas Keller", - "email": "me@kelunik.com" - }, - { - "name": "Daniel Lowrey" - } - ], - "description": "Uri Parser and Resolver.", - "homepage": "https://github.com/amphp/uri", - "time": "2019-05-13T18:25:34+00:00" - }, - { - "name": "amphp/websocket-client", - "version": "v0.2.4", - "source": { - "type": "git", - "url": "https://github.com/amphp/websocket-client.git", - "reference": "6f25a62f1e19d27797c4114091d340b36b550aa0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/amphp/websocket-client/zipball/6f25a62f1e19d27797c4114091d340b36b550aa0", - "reference": "6f25a62f1e19d27797c4114091d340b36b550aa0", - "shasum": "" - }, - "require": { - "amphp/amp": "^2", - "amphp/byte-stream": "^1", - "amphp/http": "^1", - "amphp/socket": "^0.10", - "league/uri-schemes": "^1.2", - "php": ">=7" - }, - "require-dev": { - "amphp/http-server": "^1", - "amphp/phpunit-util": "^1", - "amphp/websocket-server": "^1", - "friendsofphp/php-cs-fixer": "^2.9", - "phpunit/phpunit": "^6" - }, - "type": "library", - "autoload": { - "psr-4": { - "Amp\\Websocket\\": "lib" - }, - "files": [ - "lib/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bob Weinand", - "email": "bobwei9@hotmail.com" - }, - { - "name": "Niklas Keller", - "email": "me@kelunik.com" - }, - { - "name": "Aaron Piotrowski", - "email": "aaron@trowski.com" - } - ], - "description": "Async WebSocket client for PHP based on Amp.", - "keywords": [ - "amp", - "amphp", - "async", - "client", - "http", - "non-blocking", - "websocket" - ], - "time": "2019-02-06T15:35:13+00:00" - }, - { - "name": "amphp/windows-registry", - "version": "v0.3.2", - "source": { - "type": "git", - "url": "https://github.com/amphp/windows-registry.git", - "reference": "834af7a30ad7c006b0326ccd2686ddc6e6943366" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/amphp/windows-registry/zipball/834af7a30ad7c006b0326ccd2686ddc6e6943366", - "reference": "834af7a30ad7c006b0326ccd2686ddc6e6943366", - "shasum": "" - }, - "require": { - "amphp/amp": "^2", - "amphp/byte-stream": "^1.4", - "amphp/process": "^1" - }, - "require-dev": { - "amphp/php-cs-fixer-config": "dev-master" - }, - "type": "library", - "autoload": { - "psr-4": { - "Amp\\WindowsRegistry\\": "lib" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Niklas Keller", - "email": "me@kelunik.com" - } - ], - "description": "Windows Registry Reader.", - "time": "2018-10-24T03:34:54+00:00" - }, - { - "name": "daverandom/libdns", - "version": "v2.0.1", - "source": { - "type": "git", - "url": "https://github.com/DaveRandom/LibDNS.git", - "reference": "1ecd825b6fa9bb3fddc07751997e29dc78749b95" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/DaveRandom/LibDNS/zipball/1ecd825b6fa9bb3fddc07751997e29dc78749b95", - "reference": "1ecd825b6fa9bb3fddc07751997e29dc78749b95", - "shasum": "" - }, - "require": { - "ext-ctype": "*", - "php": ">=7.0" - }, - "suggest": { - "ext-intl": "Required for IDN support" - }, - "type": "library", - "autoload": { - "psr-4": { - "LibDNS\\": "src/" - }, - "files": [ - "src/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "DNS protocol implementation written in pure PHP", - "keywords": [ - "dns" - ], - "time": "2018-01-10T15:56:17+00:00" - }, - { - "name": "guzzlehttp/guzzle", - "version": "6.4.1", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "0895c932405407fd3a7368b6910c09a24d26db11" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/0895c932405407fd3a7368b6910c09a24d26db11", - "reference": "0895c932405407fd3a7368b6910c09a24d26db11", - "shasum": "" - }, - "require": { - "ext-json": "*", - "guzzlehttp/promises": "^1.0", - "guzzlehttp/psr7": "^1.6.1", - "php": ">=5.5" - }, - "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", - "psr/log": "^1.1" - }, - "suggest": { - "psr/log": "Required for using the Log middleware" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "6.3-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle is a PHP HTTP client library", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "rest", - "web service" - ], - "time": "2019-10-23T15:58:00+00:00" - }, - { - "name": "guzzlehttp/promises", - "version": "v1.3.1", - "source": { - "type": "git", - "url": "https://github.com/guzzle/promises.git", - "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646", - "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646", - "shasum": "" - }, - "require": { - "php": ">=5.5.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Promise\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle promises library", - "keywords": [ - "promise" - ], - "time": "2016-12-20T10:07:11+00:00" - }, - { - "name": "guzzlehttp/psr7", - "version": "1.6.1", - "source": { - "type": "git", - "url": "https://github.com/guzzle/psr7.git", - "reference": "239400de7a173fe9901b9ac7c06497751f00727a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a", - "reference": "239400de7a173fe9901b9ac7c06497751f00727a", - "shasum": "" - }, - "require": { - "php": ">=5.4.0", - "psr/http-message": "~1.0", - "ralouphie/getallheaders": "^2.0.5 || ^3.0.0" - }, - "provide": { - "psr/http-message-implementation": "1.0" - }, - "require-dev": { - "ext-zlib": "*", - "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8" - }, - "suggest": { - "zendframework/zend-httphandlerrunner": "Emit PSR-7 responses" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.6-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Psr7\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Tobias Schultze", - "homepage": "https://github.com/Tobion" - } - ], - "description": "PSR-7 message implementation that also provides common utility methods", - "keywords": [ - "http", - "message", - "psr-7", - "request", - "response", - "stream", - "uri", - "url" - ], - "time": "2019-07-01T23:21:34+00:00" - }, - { - "name": "league/uri-interfaces", - "version": "1.1.1", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/uri-interfaces.git", - "reference": "081760c53a4ce76c9935a755a21353610f5495f6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/uri-interfaces/zipball/081760c53a4ce76c9935a755a21353610f5495f6", - "reference": "081760c53a4ce76c9935a755a21353610f5495f6", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.0.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "League\\Uri\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ignace Nyamagana Butera", - "email": "nyamsprod@gmail.com", - "homepage": "https://nyamsprod.com" - } - ], - "description": "Common interface for URI representation", - "homepage": "http://github.com/thephpleague/uri-interfaces", - "keywords": [ - "rfc3986", - "rfc3987", - "uri", - "url" - ], - "time": "2018-11-05T14:00:06+00:00" - }, - { - "name": "league/uri-parser", - "version": "1.4.1", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/uri-parser.git", - "reference": "671548427e4c932352d9b9279fdfa345bf63fa00" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/uri-parser/zipball/671548427e4c932352d9b9279fdfa345bf63fa00", - "reference": "671548427e4c932352d9b9279fdfa345bf63fa00", - "shasum": "" - }, - "require": { - "php": ">=7.0.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.0", - "phpstan/phpstan": "^0.9.2", - "phpstan/phpstan-phpunit": "^0.9.4", - "phpstan/phpstan-strict-rules": "^0.9.0", - "phpunit/phpunit": "^6.0" - }, - "suggest": { - "ext-intl": "Allow parsing RFC3987 compliant hosts", - "league/uri-schemes": "Allow validating and normalizing URI parsing results" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "League\\Uri\\": "src" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ignace Nyamagana Butera", - "email": "nyamsprod@gmail.com", - "homepage": "https://nyamsprod.com" - } - ], - "description": "userland URI parser RFC 3986 compliant", - "homepage": "https://github.com/thephpleague/uri-parser", - "keywords": [ - "parse_url", - "parser", - "rfc3986", - "rfc3987", - "uri", - "url" - ], - "time": "2018-11-22T07:55:51+00:00" - }, - { - "name": "league/uri-schemes", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/uri-schemes.git", - "reference": "f821a444785724bcc9bc244b1173b9d6ca4d71e6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/uri-schemes/zipball/f821a444785724bcc9bc244b1173b9d6ca4d71e6", - "reference": "f821a444785724bcc9bc244b1173b9d6ca4d71e6", - "shasum": "" - }, - "require": { - "ext-fileinfo": "*", - "league/uri-interfaces": "^1.1", - "league/uri-parser": "^1.4.0", - "php": ">=7.0.13", - "psr/http-message": "^1.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.0", - "phpstan/phpstan": "^0.9.2", - "phpstan/phpstan-phpunit": "^0.9.4", - "phpstan/phpstan-strict-rules": "^0.9.0", - "phpunit/phpunit": "^6.0" - }, - "suggest": { - "ext-intl": "Allow parsing RFC3987 compliant hosts", - "league/uri-manipulations": "Needed to easily manipulate URI objects" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "League\\Uri\\": "src" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ignace Nyamagana Butera", - "email": "nyamsprod@gmail.com", - "homepage": "https://nyamsprod.com" - } - ], - "description": "URI manipulation library", - "homepage": "http://uri.thephpleague.com", - "keywords": [ - "data-uri", - "file", - "ftp", - "http", - "https", - "parse_url", - "psr-7", - "rfc3986", - "uri", - "url", - "ws", - "wss" - ], - "time": "2018-11-26T08:09:30+00:00" - }, - { - "name": "psr/http-message", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-message.git", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP messages", - "homepage": "https://github.com/php-fig/http-message", - "keywords": [ - "http", - "http-message", - "psr", - "psr-7", - "request", - "response" - ], - "time": "2016-08-06T14:39:51+00:00" - }, - { - "name": "ralouphie/getallheaders", - "version": "3.0.3", - "source": { - "type": "git", - "url": "https://github.com/ralouphie/getallheaders.git", - "reference": "120b605dfeb996808c31b6477290a714d356e822" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", - "reference": "120b605dfeb996808c31b6477290a714d356e822", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "require-dev": { - "php-coveralls/php-coveralls": "^2.1", - "phpunit/phpunit": "^5 || ^6.5" - }, - "type": "library", - "autoload": { - "files": [ - "src/getallheaders.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ralph Khattar", - "email": "ralph.khattar@gmail.com" - } - ], - "description": "A polyfill for getallheaders.", - "time": "2019-03-08T08:55:37+00:00" - } - ], - "packages-dev": [ - { - "name": "doctrine/instantiator", - "version": "1.3.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "ae466f726242e637cebdd526a7d991b9433bacf1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/ae466f726242e637cebdd526a7d991b9433bacf1", - "reference": "ae466f726242e637cebdd526a7d991b9433bacf1", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "require-dev": { - "doctrine/coding-standard": "^6.0", - "ext-pdo": "*", - "ext-phar": "*", - "phpbench/phpbench": "^0.13", - "phpstan/phpstan-phpunit": "^0.11", - "phpstan/phpstan-shim": "^0.11", - "phpunit/phpunit": "^7.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" - } - }, - "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://www.doctrine-project.org/projects/instantiator.html", - "keywords": [ - "constructor", - "instantiate" - ], - "time": "2019-10-21T16:45:58+00:00" - }, - { - "name": "myclabs/deep-copy", - "version": "1.9.3", - "source": { - "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/007c053ae6f31bba39dfa19a7726f56e9763bbea", - "reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "replace": { - "myclabs/deep-copy": "self.version" - }, - "require-dev": { - "doctrine/collections": "^1.0", - "doctrine/common": "^2.6", - "phpunit/phpunit": "^7.1" - }, - "type": "library", - "autoload": { - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - }, - "files": [ - "src/DeepCopy/deep_copy.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Create deep copies (clones) of your objects", - "keywords": [ - "clone", - "copy", - "duplicate", - "object", - "object graph" - ], - "time": "2019-08-09T12:45:53+00:00" - }, - { - "name": "overtrue/phplint", - "version": "1.1.9", - "source": { - "type": "git", - "url": "https://github.com/overtrue/phplint.git", - "reference": "dab041512195a6bf52401a66b65dc5b19e4d09ea" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/overtrue/phplint/zipball/dab041512195a6bf52401a66b65dc5b19e4d09ea", - "reference": "dab041512195a6bf52401a66b65dc5b19e4d09ea", - "shasum": "" - }, - "require": { - "ext-json": "*", - "php": ">=5.5.9", - "symfony/console": "^3.2|^4.0", - "symfony/finder": "^3.0|^4.0", - "symfony/process": "^3.0|^4.0", - "symfony/yaml": "^3.0|^4.0" - }, - "require-dev": { - "jakub-onderka/php-console-highlighter": "^0.3.2" - }, - "bin": [ - "bin/phplint" - ], - "type": "library", - "autoload": { - "psr-4": { - "Overtrue\\PHPLint\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "overtrue", - "email": "anzhengchao@gmail.com" - } - ], - "description": "a php syntax check tool.", - "keywords": [ - "check", - "lint", - "phplint", - "syntax" - ], - "time": "2019-01-04T12:59:53+00:00" - }, - { - "name": "phar-io/manifest", - "version": "1.0.3", - "source": { - "type": "git", - "url": "https://github.com/phar-io/manifest.git", - "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", - "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-phar": "*", - "phar-io/version": "^2.0", - "php": "^5.6 || ^7.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": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - }, - { - "name": "Sebastian Heuer", - "email": "sebastian@phpeople.de", - "role": "Developer" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "Developer" - } - ], - "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", - "time": "2018-07-08T19:23:20+00:00" - }, - { - "name": "phar-io/version", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/phar-io/version.git", - "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phar-io/version/zipball/45a2ec53a73c70ce41d55cedef9063630abaf1b6", - "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - }, - { - "name": "Sebastian Heuer", - "email": "sebastian@phpeople.de", - "role": "Developer" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "Developer" - } - ], - "description": "Library for handling version information and constraints", - "time": "2018-07-08T19:19:57+00:00" - }, - { - "name": "phpdocumentor/reflection-common", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a", - "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "require-dev": { - "phpunit/phpunit": "~6" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" - } - ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", - "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" - ], - "time": "2018-08-07T13:53:10+00:00" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "4.3.2", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/b83ff7cfcfee7827e1e78b637a5904fe6a96698e", - "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e", - "shasum": "" - }, - "require": { - "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0.0 || ^2.0.0", - "phpdocumentor/type-resolver": "~0.4 || ^1.0.0", - "webmozart/assert": "^1.0" - }, - "require-dev": { - "doctrine/instantiator": "^1.0.5", - "mockery/mockery": "^1.0", - "phpunit/phpunit": "^6.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2019-09-12T14:27:41+00:00" - }, - { - "name": "phpdocumentor/type-resolver", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", - "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", - "shasum": "" - }, - "require": { - "php": "^7.1", - "phpdocumentor/reflection-common": "^2.0" - }, - "require-dev": { - "ext-tokenizer": "^7.1", - "mockery/mockery": "~1", - "phpunit/phpunit": "^7.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "time": "2019-08-22T18:11:29+00:00" - }, - { - "name": "phpspec/prophecy", - "version": "1.9.0", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/f6811d96d97bdf400077a0cc100ae56aa32b9203", - "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", - "sebastian/comparator": "^1.1|^2.0|^3.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0" - }, - "require-dev": { - "phpspec/phpspec": "^2.5|^3.2", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.8.x-dev" - } - }, - "autoload": { - "psr-4": { - "Prophecy\\": "src/Prophecy" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "time": "2019-10-03T11:07:50+00:00" - }, - { - "name": "phpunit/php-code-coverage", - "version": "7.0.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "aa0d179a13284c7420fc281fc32750e6cc7c9e2f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/aa0d179a13284c7420fc281fc32750e6cc7c9e2f", - "reference": "aa0d179a13284c7420fc281fc32750e6cc7c9e2f", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-xmlwriter": "*", - "php": "^7.2", - "phpunit/php-file-iterator": "^2.0.2", - "phpunit/php-text-template": "^1.2.1", - "phpunit/php-token-stream": "^3.1.1", - "sebastian/code-unit-reverse-lookup": "^1.0.1", - "sebastian/environment": "^4.2.2", - "sebastian/version": "^2.0.1", - "theseer/tokenizer": "^1.1.3" - }, - "require-dev": { - "phpunit/phpunit": "^8.2.2" - }, - "suggest": { - "ext-xdebug": "^2.7.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "7.0-dev" - } - }, - "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 provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "keywords": [ - "coverage", - "testing", - "xunit" - ], - "time": "2019-09-17T06:24:36+00:00" - }, - { - "name": "phpunit/php-file-iterator", - "version": "2.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "050bedf145a257b1ff02746c31894800e5122946" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/050bedf145a257b1ff02746c31894800e5122946", - "reference": "050bedf145a257b1ff02746c31894800e5122946", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.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": "2018-09-13T20:33:42+00:00" - }, - { - "name": "phpunit/php-text-template", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "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": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", - "keywords": [ - "template" - ], - "time": "2015-06-21T13:50:34+00:00" - }, - { - "name": "phpunit/php-timer", - "version": "2.1.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "1038454804406b0b5f5f520358e78c1c2f71501e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/1038454804406b0b5f5f520358e78c1c2f71501e", - "reference": "1038454804406b0b5f5f520358e78c1c2f71501e", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.1-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", - "keywords": [ - "timer" - ], - "time": "2019-06-07T04:22:29+00:00" - }, - { - "name": "phpunit/php-token-stream", - "version": "3.1.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/995192df77f63a59e47f025390d2d1fdf8f425ff", - "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": "^7.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.1-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": "2019-09-17T06:23:10+00:00" - }, - { - "name": "phpunit/phpunit", - "version": "8.4.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "67f9e35bffc0dd52d55d565ddbe4230454fd6a4e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/67f9e35bffc0dd52d55d565ddbe4230454fd6a4e", - "reference": "67f9e35bffc0dd52d55d565ddbe4230454fd6a4e", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.2.0", - "ext-dom": "*", - "ext-json": "*", - "ext-libxml": "*", - "ext-mbstring": "*", - "ext-xml": "*", - "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.9.1", - "phar-io/manifest": "^1.0.3", - "phar-io/version": "^2.0.1", - "php": "^7.2", - "phpspec/prophecy": "^1.8.1", - "phpunit/php-code-coverage": "^7.0.7", - "phpunit/php-file-iterator": "^2.0.2", - "phpunit/php-text-template": "^1.2.1", - "phpunit/php-timer": "^2.1.2", - "sebastian/comparator": "^3.0.2", - "sebastian/diff": "^3.0.2", - "sebastian/environment": "^4.2.2", - "sebastian/exporter": "^3.1.1", - "sebastian/global-state": "^3.0.0", - "sebastian/object-enumerator": "^3.0.3", - "sebastian/resource-operations": "^2.0.1", - "sebastian/type": "^1.1.3", - "sebastian/version": "^2.0.1" - }, - "require-dev": { - "ext-pdo": "*" - }, - "suggest": { - "ext-soap": "*", - "ext-xdebug": "*", - "phpunit/php-invoker": "^2.0.0" - }, - "bin": [ - "phpunit" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "8.4-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "The PHP Unit Testing framework.", - "homepage": "https://phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ], - "time": "2019-11-06T09:42:23+00:00" - }, - { - "name": "psr/container", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", - "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" - ], - "time": "2017-02-14T16:28:37+00:00" - }, - { - "name": "sebastian/code-unit-reverse-lookup", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^5.7 || ^6.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": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Looks up which function or method a line of code belongs to", - "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "time": "2017-03-04T06:30:41+00:00" - }, - { - "name": "sebastian/comparator", - "version": "3.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5de4fc177adf9bce8df98d8d141a7559d7ccf6da", - "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da", - "shasum": "" - }, - "require": { - "php": "^7.1", - "sebastian/diff": "^3.0", - "sebastian/exporter": "^3.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-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": "https://github.com/sebastianbergmann/comparator", - "keywords": [ - "comparator", - "compare", - "equality" - ], - "time": "2018-07-12T15:12:46+00:00" - }, - { - "name": "sebastian/diff", - "version": "3.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/720fcc7e9b5cf384ea68d9d930d480907a0c1a29", - "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.5 || ^8.0", - "symfony/process": "^2 || ^3.3 || ^4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-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": "https://github.com/sebastianbergmann/diff", - "keywords": [ - "diff", - "udiff", - "unidiff", - "unified diff" - ], - "time": "2019-02-04T06:01:07+00:00" - }, - { - "name": "sebastian/environment", - "version": "4.2.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/f2a2c8e1c97c11ace607a7a667d73d47c19fe404", - "reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.5" - }, - "suggest": { - "ext-posix": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.2-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": "2019-05-05T09:05:15+00:00" - }, - { - "name": "sebastian/exporter", - "version": "3.1.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/68609e1261d215ea5b21b7987539cbfbe156ec3e", - "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e", - "shasum": "" - }, - "require": { - "php": "^7.0", - "sebastian/recursion-context": "^3.0" - }, - "require-dev": { - "ext-mbstring": "*", - "phpunit/phpunit": "^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.1.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "http://www.github.com/sebastianbergmann/exporter", - "keywords": [ - "export", - "exporter" - ], - "time": "2019-09-14T09:02:43+00:00" - }, - { - "name": "sebastian/global-state", - "version": "3.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4", - "reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4", - "shasum": "" - }, - "require": { - "php": "^7.2", - "sebastian/object-reflector": "^1.1.1", - "sebastian/recursion-context": "^3.0" - }, - "require-dev": { - "ext-dom": "*", - "phpunit/phpunit": "^8.0" - }, - "suggest": { - "ext-uopz": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", - "keywords": [ - "global state" - ], - "time": "2019-02-01T05:30:01+00:00" - }, - { - "name": "sebastian/object-enumerator", - "version": "3.0.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", - "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", - "shasum": "" - }, - "require": { - "php": "^7.0", - "sebastian/object-reflector": "^1.1.1", - "sebastian/recursion-context": "^3.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Traverses array structures and object graphs to enumerate all referenced objects", - "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "time": "2017-08-03T12:35:26+00:00" - }, - { - "name": "sebastian/object-reflector", - "version": "1.1.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "773f97c67f28de00d397be301821b06708fca0be" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be", - "reference": "773f97c67f28de00d397be301821b06708fca0be", - "shasum": "" - }, - "require": { - "php": "^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Allows reflection of object attributes, including inherited and non-public ones", - "homepage": "https://github.com/sebastianbergmann/object-reflector/", - "time": "2017-03-29T09:07:27+00:00" - }, - { - "name": "sebastian/recursion-context", - "version": "3.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", - "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", - "shasum": "" - }, - "require": { - "php": "^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.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": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2017-03-03T06:23:57+00:00" - }, - { - "name": "sebastian/resource-operations", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/4d7a795d35b889bf80a0cc04e08d77cedfa917a9", - "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides a list of PHP built-in functions that operate on resources", - "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "time": "2018-10-04T04:07:39+00:00" - }, - { - "name": "sebastian/type", - "version": "1.1.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/type.git", - "reference": "3aaaa15fa71d27650d62a948be022fe3b48541a3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/3aaaa15fa71d27650d62a948be022fe3b48541a3", - "reference": "3aaaa15fa71d27650d62a948be022fe3b48541a3", - "shasum": "" - }, - "require": { - "php": "^7.2" - }, - "require-dev": { - "phpunit/phpunit": "^8.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Collection of value objects that represent the types of the PHP type system", - "homepage": "https://github.com/sebastianbergmann/type", - "time": "2019-07-02T08:10:15+00:00" - }, - { - "name": "sebastian/version", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "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": "2016-10-03T07:35:21+00:00" - }, - { - "name": "symfony/console", - "version": "v4.3.6", - "source": { - "type": "git", - "url": "https://github.com/symfony/console.git", - "reference": "136c4bd62ea871d00843d1bc0316de4c4a84bb78" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/136c4bd62ea871d00843d1bc0316de4c4a84bb78", - "reference": "136c4bd62ea871d00843d1bc0316de4c4a84bb78", - "shasum": "" - }, - "require": { - "php": "^7.1.3", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php73": "^1.8", - "symfony/service-contracts": "^1.1" - }, - "conflict": { - "symfony/dependency-injection": "<3.4", - "symfony/event-dispatcher": "<4.3", - "symfony/process": "<3.3" - }, - "provide": { - "psr/log-implementation": "1.0" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~3.4|~4.0", - "symfony/dependency-injection": "~3.4|~4.0", - "symfony/event-dispatcher": "^4.3", - "symfony/lock": "~3.4|~4.0", - "symfony/process": "~3.4|~4.0", - "symfony/var-dumper": "^4.3" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/lock": "", - "symfony/process": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.3-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Console\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Console Component", - "homepage": "https://symfony.com", - "time": "2019-10-30T12:58:49+00:00" - }, - { - "name": "symfony/finder", - "version": "v4.3.6", - "source": { - "type": "git", - "url": "https://github.com/symfony/finder.git", - "reference": "72a068f77e317ae77c0a0495236ad292cfb5ce6f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/72a068f77e317ae77c0a0495236ad292cfb5ce6f", - "reference": "72a068f77e317ae77c0a0495236ad292cfb5ce6f", - "shasum": "" - }, - "require": { - "php": "^7.1.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.3-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Finder\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Finder Component", - "homepage": "https://symfony.com", - "time": "2019-10-30T12:53:54+00:00" - }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.12.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "550ebaac289296ce228a706d0867afc34687e3f4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/550ebaac289296ce228a706d0867afc34687e3f4", - "reference": "550ebaac289296ce228a706d0867afc34687e3f4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.12-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "time": "2019-08-06T08:03:45+00:00" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.12.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/b42a2f66e8f1b15ccf25652c3424265923eb4f17", - "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.12-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "time": "2019-08-06T08:03:45+00:00" - }, - { - "name": "symfony/polyfill-php73", - "version": "v1.12.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "2ceb49eaccb9352bff54d22570276bb75ba4a188" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/2ceb49eaccb9352bff54d22570276bb75ba4a188", - "reference": "2ceb49eaccb9352bff54d22570276bb75ba4a188", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.12-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php73\\": "" - }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "time": "2019-08-06T08:03:45+00:00" - }, - { - "name": "symfony/process", - "version": "v4.3.6", - "source": { - "type": "git", - "url": "https://github.com/symfony/process.git", - "reference": "3b2e0cb029afbb0395034509291f21191d1a4db0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/3b2e0cb029afbb0395034509291f21191d1a4db0", - "reference": "3b2e0cb029afbb0395034509291f21191d1a4db0", - "shasum": "" - }, - "require": { - "php": "^7.1.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.3-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Process\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Process Component", - "homepage": "https://symfony.com", - "time": "2019-10-28T17:07:32+00:00" - }, - { - "name": "symfony/service-contracts", - "version": "v1.1.8", - "source": { - "type": "git", - "url": "https://github.com/symfony/service-contracts.git", - "reference": "ffc7f5692092df31515df2a5ecf3b7302b3ddacf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/ffc7f5692092df31515df2a5ecf3b7302b3ddacf", - "reference": "ffc7f5692092df31515df2a5ecf3b7302b3ddacf", - "shasum": "" - }, - "require": { - "php": "^7.1.3", - "psr/container": "^1.0" - }, - "suggest": { - "symfony/service-implementation": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Contracts\\Service\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Generic abstractions related to writing services", - "homepage": "https://symfony.com", - "keywords": [ - "abstractions", - "contracts", - "decoupling", - "interfaces", - "interoperability", - "standards" - ], - "time": "2019-10-14T12:27:06+00:00" - }, - { - "name": "symfony/yaml", - "version": "v4.3.6", - "source": { - "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "324cf4b19c345465fad14f3602050519e09e361d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/324cf4b19c345465fad14f3602050519e09e361d", - "reference": "324cf4b19c345465fad14f3602050519e09e361d", - "shasum": "" - }, - "require": { - "php": "^7.1.3", - "symfony/polyfill-ctype": "~1.8" - }, - "conflict": { - "symfony/console": "<3.4" - }, - "require-dev": { - "symfony/console": "~3.4|~4.0" - }, - "suggest": { - "symfony/console": "For validating YAML files using the lint command" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.3-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Yaml Component", - "homepage": "https://symfony.com", - "time": "2019-10-30T12:58:49+00:00" - }, - { - "name": "theseer/tokenizer", - "version": "1.1.3", - "source": { - "type": "git", - "url": "https://github.com/theseer/tokenizer.git", - "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/11336f6f84e16a720dae9d8e6ed5019efa85a0f9", - "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": "^7.0" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - } - ], - "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", - "time": "2019-06-13T22:48:21+00:00" - }, - { - "name": "webmozart/assert", - "version": "1.5.0", - "source": { - "type": "git", - "url": "https://github.com/webmozart/assert.git", - "reference": "88e6d84706d09a236046d686bbea96f07b3a34f4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/88e6d84706d09a236046d686bbea96f07b3a34f4", - "reference": "88e6d84706d09a236046d686bbea96f07b3a34f4", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0", - "symfony/polyfill-ctype": "^1.8" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.36 || ^7.5.13" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, - "autoload": { - "psr-4": { - "Webmozart\\Assert\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Assertions to validate method input/output with nice error messages.", - "keywords": [ - "assert", - "check", - "validate" - ], - "time": "2019-08-24T08:43:50+00:00" - } - ], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": [], - "platform-dev": [] -} diff --git a/phpunit.xml b/phpunit.xml index f489fa4..50f56dc 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,7 +1,6 @@ - ./src - ./tests + ./tests - \ No newline at end of file + diff --git a/src/Polygon.php b/src/Polygon.php deleted file mode 100644 index 56c8493..0000000 --- a/src/Polygon.php +++ /dev/null @@ -1,23 +0,0 @@ -api_key = $apiKey; - $this->rest = new Rest($apiKey); - $this->websockets = new Websockets($apiKey); - } -} \ No newline at end of file diff --git a/src/PolygonIO.php b/src/PolygonIO.php new file mode 100644 index 0000000..aabdea0 --- /dev/null +++ b/src/PolygonIO.php @@ -0,0 +1,60 @@ +apiKey = $apiKey; + + $this->rest = new Rest($apiKey); + $this->websockets = new Websockets($apiKey); + } + + /** + * @return Rest + */ + public function rest(): Rest + { + return new Rest($this->apiKey); + } + + /** + * @return Websockets + */ + public function websockets(): Websockets + { + return new Websockets($this->apiKey); + } +} diff --git a/src/Rest/Common/Mappers.php b/src/Rest/Common/Mappers.php new file mode 100644 index 0000000..a510df5 --- /dev/null +++ b/src/Rest/Common/Mappers.php @@ -0,0 +1,176 @@ + 'c', + 'bidExchange' => 'bE', + 'askExchange' => 'aE', + 'askPrice' => 'aP', + 'buyPrice' => 'bP', + 'bidSize' => 'bS', + 'askSize' => 'aS', + 'timestamp' => 't', + ], $tick); + } + + /** + * @param $mapFields + * @param $snap + * + * @return mixed + */ + public static function map(array $mapFields, array $snap): array + { + foreach ($mapFields as $field => $responseField) { + $snap[$field] = isset($snap[$responseField]) ? $snap[$responseField] : null; + } + + return $snap; + } + + /** + * @param array $snap + * + * @return array|mixed + */ + public static function snapshotAggV2(array $snap): array + { + return self::map([ + 'tickerSymbol' => 'T', + 'volume' => 'v', + 'open' => 'o', + 'close' => 'c', + 'high' => 'h', + 'low' => 'l', + 'timestamp' => 't', + 'numberOfItems' => 'n', + ], $snap); + } + + /** + * @param array $item + * + * @return array + */ + public static function cryptoSnapshotBookItem(array $item): array + { + $mapperFields = [ + 'price' => 'p', + ]; + + return self::map($mapperFields, $item); + } + + /** + * @param array $snap + * + * @return array + */ + public static function snapshotTicker(array $snap): array + { + $snap['day'] = Mappers::snapshotAgg($snap['day']); + $snap['lastTrade'] = Mappers::tradeV1($snap['lastTrade']); + $snap['lastQuote'] = Mappers::snapshotQuote($snap['lastQuote']); + $snap['min'] = Mappers::snapshotAgg($snap['min']); + $snap['prevDay'] = Mappers::snapshotAgg($snap['prevDay']); + + return $snap; + } + + /** + * @param array $snap + * + * @return array + */ + public static function snapshotAgg(array $snap): array + { + return self::map([ + 'close' => 'c', + 'high' => 'h', + 'low' => 'l', + 'open' => 'o', + 'volume' => 'v', + ], $snap); + } + + /** + * @param array $tick + * + * @return array + */ + public static function tradeV1(array $tick): array + { + return self::map([ + 'condition1' => 'c1', + 'condition2' => 'c2', + 'condition3' => 'c3', + 'condition4' => 'c4', + 'exchange' => 'e', + 'price' => 'p', + 'size' => 's', + 'timestamp' => 't', + ], $tick); + } + + /** + * @param array $q + * + * @return array + */ + public static function snapshotQuote(array $q): array + { + return self::map([ + 'bidPrice' => 'p', + 'bidSize' => 's', + 'askPrice' => 'P', + 'askSize' => 'S', + 'lastUpdateTimestamp' => 't', + ], $q); + } + + /** + * @param array $snap + * + * @return array + */ + public static function snapshotCryptoTicker(array $snap): array + { + $snap['day'] = Mappers::snapshotAgg($snap['day']); + $snap['lastTrade'] = Mappers::cryptoTick($snap['lastTrade']); + $snap['min'] = Mappers::snapshotAgg($snap['min']); + $snap['prevDay'] = Mappers::snapshotAgg($snap['prevDay']); + + return $snap; + } + + /** + * @param array $tick + * + * @return array + */ + public static function cryptoTick(array $tick): array + { + return self::map([ + 'price' => 'p', + 'size' => 's', + 'exchange' => 'x', + 'conditions' => 'c', + 'timestamp' => 't', + ], $tick); + } +} diff --git a/src/Rest/Crypto/Aggregates.php b/src/Rest/Crypto/Aggregates.php new file mode 100644 index 0000000..594401e --- /dev/null +++ b/src/Rest/Crypto/Aggregates.php @@ -0,0 +1,48 @@ +_get('/v2/aggs/ticker/' . $tickerSymbol . '/range/' . $multiplier . '/' . $timespan . '/' . $from . '/' . $to, $params); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + $response['results'] = array_map( + function ($result) { + return Mappers::snapshotAggV2($result); + }, + $response['results'] + ); + + return $response; + } +} diff --git a/src/Rest/Crypto/Crypto.php b/src/Rest/Crypto/Crypto.php new file mode 100644 index 0000000..9137c91 --- /dev/null +++ b/src/Rest/Crypto/Crypto.php @@ -0,0 +1,189 @@ +apiKey = $apiKey; + + $this->previousClose = new PreviousClose($apiKey); + $this->groupedDaily = new GroupedDaily($apiKey); + $this->aggregates = new Aggregates($apiKey); + $this->cryptoExchanges = new CryptoExchanges($apiKey); + $this->lastTradeForCryptoPair = new LastTradeForCryptoPair($apiKey); + $this->dailyOpenClose = new DailyOpenClose($apiKey); + $this->historicCryptoTrade = new HistoricCryptoTrade($apiKey); + $this->snapshotAllTickers = new SnapshotAllTickers($apiKey); + $this->snapshotGainersLosers = new SnapshotGainersLosers($apiKey); + $this->snapshotSingleTicker = new SnapshotSingleTicker($apiKey); + $this->snapshotSingleTickerFullBook = new SnapshotSingleTickerFullBook($apiKey); + } + + /** + * @return PreviousClose + */ + public function previousClose(): PreviousClose + { + return new PreviousClose($this->apiKey); + } + + /** + * @return GroupedDaily + */ + public function groupedDaily(): GroupedDaily + { + return new GroupedDaily($this->apiKey); + } + + /** + * @return Aggregates + */ + public function aggregates(): Aggregates + { + return new Aggregates($this->apiKey); + } + + /** + * @return CryptoExchanges + */ + public function cryptoExchanges(): CryptoExchanges + { + return new CryptoExchanges($this->apiKey); + } + + /** + * @return LastTradeForCryptoPair + */ + public function lastTradeForCryptoPair(): LastTradeForCryptoPair + { + return new LastTradeForCryptoPair($this->apiKey); + } + + /** + * @return DailyOpenClose + */ + public function dailyOpenClose(): DailyOpenClose + { + return new DailyOpenClose($this->apiKey); + } + + /** + * @return HistoricCryptoTrade + */ + public function historicCryptoTrade(): HistoricCryptoTrade + { + return new HistoricCryptoTrade($this->apiKey); + } + + /** + * @return SnapshotAllTickers + */ + public function snapshotAllTickers(): SnapshotAllTickers + { + return new SnapshotAllTickers($this->apiKey); + } + + /** + * @return SnapshotGainersLosers + */ + public function snapshotGainersLosers(): SnapshotGainersLosers + { + return new SnapshotGainersLosers($this->apiKey); + } + + /** + * @return SnapshotSingleTicker + */ + public function snapshotSingleTicker(): SnapshotSingleTicker + { + return new SnapshotSingleTicker($this->apiKey); + } + + /** + * @return SnapshotSingleTickerFullBook + */ + public function snapshotSingleTickerFullBook(): SnapshotSingleTickerFullBook + { + return new SnapshotSingleTickerFullBook($this->apiKey); + } +} diff --git a/src/Rest/Crypto/CryptoExchanges.php b/src/Rest/Crypto/CryptoExchanges.php new file mode 100644 index 0000000..04a236f --- /dev/null +++ b/src/Rest/Crypto/CryptoExchanges.php @@ -0,0 +1,24 @@ +_get($this->route); + } +} diff --git a/src/Rest/Crypto/DailyOpenClose.php b/src/Rest/Crypto/DailyOpenClose.php new file mode 100644 index 0000000..3468641 --- /dev/null +++ b/src/Rest/Crypto/DailyOpenClose.php @@ -0,0 +1,47 @@ +_get('/v1/open-close/crypto/' . $from . '/' . $to . '/' . $date); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + if (array_key_exists('openTrades', $response)) { + $response['openTrades'] = array_map(Mappers::cryptoTick, $response['openTrades']); + } + + if (array_key_exists('closingTrades', $response)) { + $response['closingTrades'] = array_map(Mappers::cryptoTick, $response['closingTrades']); + } + + return $response; + } +} diff --git a/src/Rest/Crypto/GroupedDaily.php b/src/Rest/Crypto/GroupedDaily.php new file mode 100644 index 0000000..e82e4c6 --- /dev/null +++ b/src/Rest/Crypto/GroupedDaily.php @@ -0,0 +1,47 @@ +_get('/v2/aggs/grouped/locale/' . $locale . '/market/' . $market . '/' . $date, $params); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + $response['results'] = array_map( + function ($result) { + return Mappers::snapshotAggV2($result); + }, + $response['results'] + ); + + return $response; + } +} diff --git a/src/Rest/Crypto/HistoricCryptoTrade.php b/src/Rest/Crypto/HistoricCryptoTrade.php new file mode 100644 index 0000000..65db575 --- /dev/null +++ b/src/Rest/Crypto/HistoricCryptoTrade.php @@ -0,0 +1,50 @@ + 100, + ]; + + /** + * @param $from + * @param $to + * @param $date + * @param array $params + * + * @return array + * + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function get($from, $to, $date, $params = []): array + { + return $this->_get('/v1/historic/crypto/' . $from . '/' . $to . '/' . $date, $params); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + $response['ticks'] = array_map( + function ($tick) { + return Mappers::cryptoTick($tick); + }, + $response['ticks'] + ); + return $response; + } +} diff --git a/src/Rest/Crypto/LastTradeForCryptoPair.php b/src/Rest/Crypto/LastTradeForCryptoPair.php new file mode 100644 index 0000000..fdee48b --- /dev/null +++ b/src/Rest/Crypto/LastTradeForCryptoPair.php @@ -0,0 +1,21 @@ +_get('/v1/last/crypto/' . $from . '/' . $to); + } +} diff --git a/src/Rest/Crypto/PreviousClose.php b/src/Rest/Crypto/PreviousClose.php new file mode 100644 index 0000000..cc6defb --- /dev/null +++ b/src/Rest/Crypto/PreviousClose.php @@ -0,0 +1,45 @@ +_get('/v2/aggs/ticker/' . $tickerSymbol . '/prev', $params); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + $response['results'] = array_map( + function ($result) { + return Mappers::snapshotAggV2($result); + }, + $response['results'] + ); + + return $response; + } +} diff --git a/src/Rest/Crypto/SnapshotAllTickers.php b/src/Rest/Crypto/SnapshotAllTickers.php new file mode 100644 index 0000000..e1c84e9 --- /dev/null +++ b/src/Rest/Crypto/SnapshotAllTickers.php @@ -0,0 +1,42 @@ +_get('/v2/snapshot/locale/global/markets/crypto/tickers'); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + $response['tickers'] = array_map( + function ($ticker) { + return Mappers::snapshotCryptoTicker($ticker); + }, + $response['tickers'] + ); + + return $response; + } +} diff --git a/src/Rest/Crypto/SnapshotGainersLosers.php b/src/Rest/Crypto/SnapshotGainersLosers.php new file mode 100644 index 0000000..f2a3032 --- /dev/null +++ b/src/Rest/Crypto/SnapshotGainersLosers.php @@ -0,0 +1,44 @@ +_get('/v2/snapshot/locale/global/markets/crypto/' . $direction); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + $response['tickers'] = array_map( + function ($ticker) { + return Mappers::snapshotTicker($ticker); + }, + $response['tickers'] + ); + + return $response; + } +} diff --git a/src/Rest/Crypto/SnapshotSingleTicker.php b/src/Rest/Crypto/SnapshotSingleTicker.php new file mode 100644 index 0000000..b12be33 --- /dev/null +++ b/src/Rest/Crypto/SnapshotSingleTicker.php @@ -0,0 +1,39 @@ +_get('/v2/snapshot/locale/global/markets/crypto/tickers/' . $tickerSymbol); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + $response['ticker'] = Mappers::snapshotCryptoTicker($response['ticker']); + + return $response; + } +} diff --git a/src/Rest/Crypto/SnapshotSingleTickerFullBook.php b/src/Rest/Crypto/SnapshotSingleTickerFullBook.php new file mode 100644 index 0000000..00e74ad --- /dev/null +++ b/src/Rest/Crypto/SnapshotSingleTickerFullBook.php @@ -0,0 +1,48 @@ +_get('/v2/snapshot/locale/global/markets/crypto/tickers/' . $tickerSymbol . '/book'); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + if (array_key_exists('asks', $response['data'])) { + $response['data']['asks'] = array_merge( + function ($ask) { + return Mappers::cryptoSnapshotBookItem($ask); + }, + $response['data']['asks'] + ); + } + if (array_key_exists('bids', $response['data'])) { + $response['data']['bids'] = array_merge( + function ($bid) { + return Mappers::cryptoSnapshotBookItem($bid); + }, + $response['data']['bids'] + ); + } + + return $response; + } +} diff --git a/src/Rest/Forex/Aggregates.php b/src/Rest/Forex/Aggregates.php new file mode 100644 index 0000000..0ddf44d --- /dev/null +++ b/src/Rest/Forex/Aggregates.php @@ -0,0 +1,48 @@ +_get('/v2/aggs/ticker/' . $tickerSymbol . '/range/' . $multiplier . '/' . $timespan . '/' . $from . '/' . $to, $params); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + $response['results'] = array_map( + function ($result) { + return Mappers::snapshotAggV2($result); + }, + $response['results'] + ); + + return $response; + } +} diff --git a/src/Rest/Forex/Forex.php b/src/Rest/Forex/Forex.php new file mode 100644 index 0000000..5415182 --- /dev/null +++ b/src/Rest/Forex/Forex.php @@ -0,0 +1,139 @@ +apiKey = $apiKey; + + $this->groupedDaily = new GroupedDaily($apiKey); + $this->aggregates = new Aggregates($apiKey); + $this->previousClose = new PreviousClose($apiKey); + $this->historicForexTick = new HistoricForexTick($apiKey); + $this->realTimeCurrencyConversion = new RealTimeCurrencyConversion($apiKey); + $this->lastQuoteForCurrencyPair = new LastQuoteForCurrencyPair($apiKey); + $this->snapshotAllTickers = new SnapshotAllTickers($apiKey); + $this->snapshotGainersLosers = new SnapshotGainersLosers($apiKey); + } + + /** + * @return GroupedDaily + */ + public function groupedDaily(): GroupedDaily + { + return new GroupedDaily($this->apiKey); + } + + /** + * @return Aggregates + */ + public function aggregates(): Aggregates + { + return new Aggregates($this->apiKey); + } + + /** + * @return PreviousClose + */ + public function previousClose(): PreviousClose + { + return new PreviousClose($this->apiKey); + } + + /** + * @return HistoricForexTick + */ + public function historicForexTick(): HistoricForexTick + { + return new HistoricForexTick($this->apiKey); + } + + /** + * @return RealTimeCurrencyConversion + */ + public function realTimeCurrencyConversion(): RealTimeCurrencyConversion + { + return new RealTimeCurrencyConversion($this->apiKey); + } + + /** + * @return LastQuoteForCurrencyPair + */ + public function lastQuoteForCurrencyPair(): LastQuoteForCurrencyPair + { + return new LastQuoteForCurrencyPair($this->apiKey); + } + + /** + * @return SnapshotAllTickers + */ + public function snapshotAllTickers(): SnapshotAllTickers + { + return new SnapshotAllTickers($this->apiKey); + } + + /** + * @return SnapshotGainersLosers + */ + public function snapshotGainersLosers(): SnapshotGainersLosers + { + return new SnapshotGainersLosers($this->apiKey); + } +} diff --git a/src/Rest/Forex/GroupedDaily.php b/src/Rest/Forex/GroupedDaily.php new file mode 100644 index 0000000..6c26a5d --- /dev/null +++ b/src/Rest/Forex/GroupedDaily.php @@ -0,0 +1,47 @@ +_get('/v2/aggs/grouped/locale/' . $locale . '/market/' . $market . '/' . $date, $params); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + $response['results'] = array_map( + function ($result) { + return Mappers::snapshotAggV2($result); + }, + $response['results'] + ); + + return $response; + } +} diff --git a/src/Rest/Forex/HistoricForexTick.php b/src/Rest/Forex/HistoricForexTick.php new file mode 100644 index 0000000..894d472 --- /dev/null +++ b/src/Rest/Forex/HistoricForexTick.php @@ -0,0 +1,32 @@ + 100, + ]; + + /** + * @param $from + * @param $to + * @param $date + * @param array $params + * + * @return array + * + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function get($from, $to, $date, $params = []): array + { + return $this->_get('/v1/historic/forex/' . $from . '/' . $to . '/' . $date, $params); + } +} diff --git a/src/Rest/Forex/LastQuoteForCurrencyPair.php b/src/Rest/Forex/LastQuoteForCurrencyPair.php new file mode 100644 index 0000000..edb7391 --- /dev/null +++ b/src/Rest/Forex/LastQuoteForCurrencyPair.php @@ -0,0 +1,26 @@ +_get('/v1/last_quote/currencies/' . $from . '/' . $to); + } +} diff --git a/src/Rest/Forex/PreviousClose.php b/src/Rest/Forex/PreviousClose.php new file mode 100644 index 0000000..4dd2dfa --- /dev/null +++ b/src/Rest/Forex/PreviousClose.php @@ -0,0 +1,45 @@ +_get('/v2/aggs/ticker/' . $tickerSymbol . '/prev', $params); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + $response['results'] = array_map( + function ($result) { + return Mappers::snapshotAggV2($result); + }, + $response['results'] + ); + + return $response; + } +} diff --git a/src/Rest/Forex/RealTimeCurrencyConversion.php b/src/Rest/Forex/RealTimeCurrencyConversion.php new file mode 100644 index 0000000..8a31eb5 --- /dev/null +++ b/src/Rest/Forex/RealTimeCurrencyConversion.php @@ -0,0 +1,32 @@ + 100, + 'precision' => 2, + ]; + + /** + * @param $from + * @param $to + * @param array $params + * + * @return array + * + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function get($from, $to, $params = []): array + { + return $this->_get('/v1/conversion/' . $from . '/' . $to, $params); + } +} diff --git a/src/Rest/Forex/SnapshotAllTickers.php b/src/Rest/Forex/SnapshotAllTickers.php new file mode 100644 index 0000000..c39b777 --- /dev/null +++ b/src/Rest/Forex/SnapshotAllTickers.php @@ -0,0 +1,41 @@ +_get('/v2/snapshot/locale/global/markets/forex/tickers'); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + $response['tickers'] = array_map( + function ($ticker) { + return Mappers::snapshotTicker($ticker); + }, + $response['tickers'] + ); + + return $response; + } +} diff --git a/src/Rest/Forex/SnapshotGainersLosers.php b/src/Rest/Forex/SnapshotGainersLosers.php new file mode 100644 index 0000000..1ce536b --- /dev/null +++ b/src/Rest/Forex/SnapshotGainersLosers.php @@ -0,0 +1,43 @@ +_get('/v2/snapshot/locale/global/markets/forex/' . $direction); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + $response['tickers'] = array_map( + function ($ticker) { + return Mappers::snapshotTicker($ticker); + }, + $response['tickers'] + ); + + return $response; + } +} diff --git a/src/Rest/Reference/Locales.php b/src/Rest/Reference/Locales.php new file mode 100644 index 0000000..e325545 --- /dev/null +++ b/src/Rest/Reference/Locales.php @@ -0,0 +1,25 @@ +_get($this->route); + } +} diff --git a/src/Rest/Reference/MarketHolidays.php b/src/Rest/Reference/MarketHolidays.php new file mode 100644 index 0000000..71e3abe --- /dev/null +++ b/src/Rest/Reference/MarketHolidays.php @@ -0,0 +1,25 @@ +_get($this->route); + } +} diff --git a/src/Rest/Reference/MarketStatus.php b/src/Rest/Reference/MarketStatus.php new file mode 100644 index 0000000..4ea1861 --- /dev/null +++ b/src/Rest/Reference/MarketStatus.php @@ -0,0 +1,25 @@ +_get($this->route); + } +} diff --git a/src/Rest/Reference/Markets.php b/src/Rest/Reference/Markets.php new file mode 100644 index 0000000..75e9a4a --- /dev/null +++ b/src/Rest/Reference/Markets.php @@ -0,0 +1,25 @@ +_get($this->route); + } +} diff --git a/src/Rest/Reference/Reference.php b/src/Rest/Reference/Reference.php new file mode 100644 index 0000000..70dba61 --- /dev/null +++ b/src/Rest/Reference/Reference.php @@ -0,0 +1,192 @@ +apiKey = $apiKey; + + $this->tickers = new Tickers($apiKey); + $this->tickerTypes = new TickerTypes($apiKey); + $this->tickerDetails = new TickerDetails($apiKey); + $this->tickerNews = new TickerNews($apiKey); + $this->markets = new Markets($apiKey); + $this->locales = new Locales($apiKey); + $this->stockSplits = new StockSplits($apiKey); + $this->stockDividends = new StockDividends($apiKey); + $this->stockFinancials = new StockFinancials($apiKey); + $this->marketStatus = new MarketStatus($apiKey); + $this->marketHolidays = new MarketHolidays($apiKey); + } + + /** + * @return Tickers + */ + public function tickers(): Tickers + { + return new Tickers($this->apiKey); + } + + /** + * @return TickerTypes + */ + public function tickerTypes(): TickerTypes + { + return new TickerTypes($this->apiKey); + } + + /** + * @return TickerDetails + */ + public function tickerDetails(): TickerDetails + { + return new TickerDetails($this->apiKey); + } + + /** + * @return TickerNews + */ + public function tickerNews(): TickerNews + { + return new TickerNews($this->apiKey); + } + + /** + * @return Markets + */ + public function markets(): Markets + { + return new Markets($this->apiKey); + } + + /** + * @return Locales + */ + public function locales(): Locales + { + return new Locales($this->apiKey); + } + + /** + * @return StockSplits + */ + public function stockSplits(): StockSplits + { + return new StockSplits($this->apiKey); + } + + /** + * @return StockDividends + */ + public function stockDividends(): StockDividends + { + return new StockDividends($this->apiKey); + } + + /** + * @return StockFinancials + */ + public function stockFinancials(): StockFinancials + { + return new StockFinancials($this->apiKey); + } + + /** + * @return MarketStatus + */ + public function marketStatus(): MarketStatus + { + return new MarketStatus($this->apiKey); + } + + /** + * @return MarketHolidays + */ + public function marketHolidays(): MarketHolidays + { + return new MarketHolidays($this->apiKey); + } +} diff --git a/src/Rest/Reference/StockDividends.php b/src/Rest/Reference/StockDividends.php new file mode 100644 index 0000000..60c7b71 --- /dev/null +++ b/src/Rest/Reference/StockDividends.php @@ -0,0 +1,25 @@ +_get('/v2/reference/dividends/' . $tickerSymbol); + } +} diff --git a/src/Rest/Reference/StockFinancials.php b/src/Rest/Reference/StockFinancials.php new file mode 100644 index 0000000..7c16c20 --- /dev/null +++ b/src/Rest/Reference/StockFinancials.php @@ -0,0 +1,30 @@ + 5, + ]; + + /** + * @param $tickerSymbol + * @param $params + * + * @return mixed + * + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function get(string $tickerSymbol, array $params = []) + { + return $this->_get('/v2/reference/financials/' . $tickerSymbol, $params); + } +} diff --git a/src/Rest/Reference/StockSplits.php b/src/Rest/Reference/StockSplits.php new file mode 100644 index 0000000..bcb260b --- /dev/null +++ b/src/Rest/Reference/StockSplits.php @@ -0,0 +1,25 @@ +_get('/v2/reference/splits/' . $tickerSymbol); + } +} diff --git a/src/Rest/Reference/TickerDetails.php b/src/Rest/Reference/TickerDetails.php new file mode 100644 index 0000000..a05acc3 --- /dev/null +++ b/src/Rest/Reference/TickerDetails.php @@ -0,0 +1,42 @@ +_get('/v1/meta/symbols/' . $tickerSymbol . '/company'); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + $mapperFields = [ + 'legalEntityIdentifier' => 'lei', + 'standardIndustryClassification' => 'sic', + ]; + + return Mappers::map($mapperFields, $response); + } +} diff --git a/src/Rest/Reference/TickerNews.php b/src/Rest/Reference/TickerNews.php new file mode 100644 index 0000000..340b53f --- /dev/null +++ b/src/Rest/Reference/TickerNews.php @@ -0,0 +1,31 @@ + 50, + 'page' => 1, + ]; + + /** + * @param $tickerSymbol + * @param array $params + * + * @return array + * + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function get(string $tickerSymbol, array $params = []): array + { + return $this->_get('/v1/meta/symbols/' . $tickerSymbol . '/news', $params); + } +} diff --git a/src/Rest/Reference/TickerTypes.php b/src/Rest/Reference/TickerTypes.php new file mode 100644 index 0000000..3421e9d --- /dev/null +++ b/src/Rest/Reference/TickerTypes.php @@ -0,0 +1,25 @@ +_get($this->route); + } +} diff --git a/src/rest/reference/Tickers.php b/src/Rest/Reference/Tickers.php similarity index 56% rename from src/rest/reference/Tickers.php rename to src/Rest/Reference/Tickers.php index f1afadd..fbb8520 100644 --- a/src/rest/reference/Tickers.php +++ b/src/Rest/Reference/Tickers.php @@ -1,13 +1,16 @@ 'ticker', @@ -16,10 +19,14 @@ class Tickers extends RestResource { ]; /** - * @param $params + * @param $params + * * @return mixed + * + * @throws \GuzzleHttp\Exception\GuzzleException */ - public function get($params = []) { + public function get(array $params = []) + { return $this->_get($this->route, $params); } -} \ No newline at end of file +} diff --git a/src/Rest/Rest.php b/src/Rest/Rest.php new file mode 100644 index 0000000..0d875b4 --- /dev/null +++ b/src/Rest/Rest.php @@ -0,0 +1,89 @@ +apiKey = $apiKey; + + $this->reference = new Reference($apiKey); + $this->stocks = new Stocks($apiKey); + $this->forex = new Forex($apiKey); + $this->crypto = new Crypto($apiKey); + } + + /** + * @return Reference + */ + public function reference(): Reference + { + return new Reference($this->apiKey); + } + + /** + * @return Stocks + */ + public function stocks(): Stocks + { + return new Stocks($this->apiKey); + } + + /** + * @return Forex + */ + public function forex(): Forex + { + return new Forex($this->apiKey); + } + + /** + * @return Crypto + */ + public function crypto(): Crypto + { + return new Crypto($this->apiKey); + } +} diff --git a/src/Rest/RestResource.php b/src/Rest/RestResource.php new file mode 100644 index 0000000..8cfc2eb --- /dev/null +++ b/src/Rest/RestResource.php @@ -0,0 +1,91 @@ +apiKey = $apiKey; + $this->httpClient = $httpClient ? $httpClient : new \GuzzleHttp\Client(); + } + + /** + * @return ClientInterface + */ + public function getHttpClient(): ClientInterface + { + return $this->httpClient; + } + + /** + * @param ClientInterface $httpClient + */ + public function setHttpClient(ClientInterface $httpClient): void + { + $this->httpClient = $httpClient; + } + + /** + * @param string $route + * @param array $params + * + * @return array + * + * @throws \GuzzleHttp\Exception\GuzzleException + */ + protected function _get(string $route, $params = []): array + { + $enhancedParams = array_merge( + [ + 'apiKey' => $this->apiKey, + ], + array_merge( + $this->defaultParams, + $params + ) + ); + + $route = $this->API_URL . $route; + $response = $this->httpClient->get( + $route, + [ + 'query' => $enhancedParams + ] + ); + + $bodyString = $response->getBody()->getContents(); + $json = json_decode($bodyString, true); + + return $this->mapper($json); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + return $response; + } +} diff --git a/src/Rest/Stocks/Aggregates.php b/src/Rest/Stocks/Aggregates.php new file mode 100644 index 0000000..2d4866c --- /dev/null +++ b/src/Rest/Stocks/Aggregates.php @@ -0,0 +1,49 @@ +_get('/v2/aggs/ticker/' . $tickerSymbol . '/range/' . $multiplier . '/' . $timespan . '/' . $from . '/' . $to, $params); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + $response['results'] = array_map( + function ($result) { + return Mappers::snapshotAggV2($result); + }, + $response['results'] + ); + + return $response; + } +} diff --git a/src/Rest/Stocks/ConditionMappings.php b/src/Rest/Stocks/ConditionMappings.php new file mode 100644 index 0000000..34fb612 --- /dev/null +++ b/src/Rest/Stocks/ConditionMappings.php @@ -0,0 +1,24 @@ +_get('/v1/meta/conditions/' . $tickTypes); + } +} diff --git a/src/Rest/Stocks/DailyOpenClose.php b/src/Rest/Stocks/DailyOpenClose.php new file mode 100644 index 0000000..0478868 --- /dev/null +++ b/src/Rest/Stocks/DailyOpenClose.php @@ -0,0 +1,26 @@ +_get('/v1/open-close/' . $tickerSymbol . '/' . $date); + } +} diff --git a/src/Rest/Stocks/Exchanges.php b/src/Rest/Stocks/Exchanges.php new file mode 100644 index 0000000..9705449 --- /dev/null +++ b/src/Rest/Stocks/Exchanges.php @@ -0,0 +1,25 @@ +_get($this->route); + } +} diff --git a/src/Rest/Stocks/GroupedDaily.php b/src/Rest/Stocks/GroupedDaily.php new file mode 100644 index 0000000..0633228 --- /dev/null +++ b/src/Rest/Stocks/GroupedDaily.php @@ -0,0 +1,47 @@ +_get('/v2/aggs/grouped/locale/' . $locale . '/market/' . $market . '/' . $date, $params); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + $response['results'] = array_map( + function ($result) { + return Mappers::snapshotAggV2($result); + }, + $response['results'] + ); + + return $response; + } +} diff --git a/src/Rest/Stocks/HistoricQuotes.php b/src/Rest/Stocks/HistoricQuotes.php new file mode 100644 index 0000000..ab456de --- /dev/null +++ b/src/Rest/Stocks/HistoricQuotes.php @@ -0,0 +1,49 @@ + 100 + ]; + + /** + * @param $tickerSymbol + * @param $date + * + * @return array + * + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function get($tickerSymbol, $date): array + { + return $this->_get('/v1/historic/quotes/' . $tickerSymbol . '/' . $date); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + $response['ticks'] = array_map( + function ($tick) { + return Mappers::quoteV1($tick); + }, + $response['ticks'] + ); + + return $response; + } +} diff --git a/src/Rest/Stocks/HistoricQuotesV2.php b/src/Rest/Stocks/HistoricQuotesV2.php new file mode 100644 index 0000000..880be3a --- /dev/null +++ b/src/Rest/Stocks/HistoricQuotesV2.php @@ -0,0 +1,69 @@ + 100 + ]; + + /** + * @param $tickerSymbol + * @param $date + * + * @return array + * + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function get($tickerSymbol, $date): array + { + return $this->_get('/v2/ticks/stocks/nbbo/' . $tickerSymbol . '/' . $date); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + $mapperFields = [ + 'ticker' => 'T', + 'SIPTimestamp' => 't', + 'participantExchangeTimestamp' => 'y', + 'tradeReportingFacilityTimestamp' => 'f', + 'sequenceNumber' => 'q', + 'conditions' => 'c', + 'indicators' => 'i', + 'bidPrice' => 'p', + 'bidExchangeId' => 'x', + 'bidSize' => 's', + 'askPrice' => 'p', + 'askExchangeId' => 'X', + 'askSize' => 'S', + 'tapeWhereTradeOccured' => 'z', + ]; + + if ($response['results']) { + $response['results'] = array_map( + function ($result) use ( + $mapperFields + ) { + return Mappers::map($mapperFields, $result); + }, + $response['results'] + ); + } + + return $response; + } +} diff --git a/src/Rest/Stocks/HistoricTrades.php b/src/Rest/Stocks/HistoricTrades.php new file mode 100644 index 0000000..650893b --- /dev/null +++ b/src/Rest/Stocks/HistoricTrades.php @@ -0,0 +1,50 @@ + 100 + ]; + + /** + * @param $tickerSymbol + * @param $date + * + * @return array + * + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function get($tickerSymbol, $date): array + { + return $this->_get('/v1/historic/trades/' . $tickerSymbol . '/' . $date); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + $response['ticks'] = array_map( + function ($tick) { + return Mappers::tradeV1($tick); + }, + $response['ticks'] + ); + + return $response; + } +} diff --git a/src/Rest/Stocks/HistoricTradesV2.php b/src/Rest/Stocks/HistoricTradesV2.php new file mode 100644 index 0000000..36f01f7 --- /dev/null +++ b/src/Rest/Stocks/HistoricTradesV2.php @@ -0,0 +1,63 @@ + 100 + ]; + + /** + * @param $tickerSymbol + * @param $date + * + * @return array + * + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function get($tickerSymbol, $date): array + { + return $this->_get('/v2/ticks/stocks/trades/' . $tickerSymbol . '/' . $date); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + $mapperFields = [ + 'ticker' => 'T', + 'SIPTimestamp' => 't', + 'participantExchangeTimestamp' => 'y', + 'tradeReportingFacilityTimestamp' => 'y', + 'sequenceNumber' => 'q', + 'tradeId' => 'i', + 'exchange' => 'x', + 'size' => 's', + 'conditions' => 'c', + 'price' => 'p', + 'tapeWhereTheTradeOccured' => 'z', + ]; + + $response['ticks'] = array_map( + function ($tick) { + + return $tick; + }, + $response['ticks'] + ); + + return $response; + } +} diff --git a/src/Rest/Stocks/LastQuoteForSymbol.php b/src/Rest/Stocks/LastQuoteForSymbol.php new file mode 100644 index 0000000..1edef98 --- /dev/null +++ b/src/Rest/Stocks/LastQuoteForSymbol.php @@ -0,0 +1,25 @@ +_get('/v1/last_quote/stocks/' . $tickerSymbol); + } +} diff --git a/src/Rest/Stocks/LastTradeForSymbol.php b/src/Rest/Stocks/LastTradeForSymbol.php new file mode 100644 index 0000000..68d3d11 --- /dev/null +++ b/src/Rest/Stocks/LastTradeForSymbol.php @@ -0,0 +1,25 @@ +_get('/v1/last/stocks/' . $tickerSymbol); + } +} diff --git a/src/Rest/Stocks/PreviousClose.php b/src/Rest/Stocks/PreviousClose.php new file mode 100644 index 0000000..ad6e9f8 --- /dev/null +++ b/src/Rest/Stocks/PreviousClose.php @@ -0,0 +1,45 @@ +_get('/v2/aggs/ticker/' . $tickerSymbol . '/prev', $params); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + $response['results'] = array_map( + function ($result) { + return Mappers::snapshotAggV2($result); + }, + $response['results'] + ); + + return $response; + } +} diff --git a/src/Rest/Stocks/SnapshotAllTickers.php b/src/Rest/Stocks/SnapshotAllTickers.php new file mode 100644 index 0000000..f6ddb8c --- /dev/null +++ b/src/Rest/Stocks/SnapshotAllTickers.php @@ -0,0 +1,41 @@ +_get('/v2/snapshot/locale/us/markets/stocks/tickers'); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + $response['tickers'] = array_map( + function ($ticker) { + return Mappers::snapshotTicker($ticker); + }, + $response['tickers'] + ); + + return $response; + } +} diff --git a/src/Rest/Stocks/SnapshotGainersLosers.php b/src/Rest/Stocks/SnapshotGainersLosers.php new file mode 100644 index 0000000..969badd --- /dev/null +++ b/src/Rest/Stocks/SnapshotGainersLosers.php @@ -0,0 +1,44 @@ +_get('/v2/snapshot/locale/us/markets/stocks/' . $direction); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + $response['tickers'] = array_map( + function ($ticker) { + return Mappers::snapshotTicker($ticker); + }, + $response['tickers'] + ); + + return $response; + } +} diff --git a/src/Rest/Stocks/SnapshotSingleTicker.php b/src/Rest/Stocks/SnapshotSingleTicker.php new file mode 100644 index 0000000..f978eb4 --- /dev/null +++ b/src/Rest/Stocks/SnapshotSingleTicker.php @@ -0,0 +1,38 @@ +_get('/v2/snapshot/locale/us/markets/stocks/tickers/' . $tickerSymbol); + } + + /** + * @param array $response + * + * @return array + */ + protected function mapper(array $response): array + { + $response['ticker'] = Mappers::snapshotTicker($response['ticker']); + + return $response; + } +} diff --git a/src/Rest/Stocks/Stocks.php b/src/Rest/Stocks/Stocks.php new file mode 100644 index 0000000..35b9e2f --- /dev/null +++ b/src/Rest/Stocks/Stocks.php @@ -0,0 +1,247 @@ +apiKey = $apiKey; + + $this->exchanges = new Exchanges($apiKey); + $this->historicTrades = new HistoricTrades($apiKey); + $this->historicTradesV2 = new HistoricTradesV2($apiKey); + $this->historicQuotes = new HistoricQuotes($apiKey); + $this->historicQuotesV2 = new HistoricQuotesV2($apiKey); + $this->lastTradeForSymbol = new LastTradeForSymbol($apiKey); + $this->lastQuoteForSymbol = new LastQuoteForSymbol($apiKey); + $this->dailyOpenClose = new DailyOpenClose($apiKey); + $this->conditionMappings = new ConditionMappings($apiKey); + $this->snapshotAllTickers = new SnapshotAllTickers($apiKey); + $this->snapshotSingleTicker = new SnapshotSingleTicker($apiKey); + $this->snapshotGainersLosers = new SnapshotGainersLosers($apiKey); + $this->previousClose = new PreviousClose($apiKey); + $this->aggregates = new Aggregates($apiKey); + $this->groupedDaily = new GroupedDaily($apiKey); + } + + /** + * @return Exchanges + */ + public function exchanges(): Exchanges + { + return new Exchanges($this->apiKey); + } + + /** + * @return HistoricTrades + */ + public function historicTrades(): HistoricTrades + { + return new HistoricTrades($this->apiKey); + } + + /** + * @return HistoricTradesV2 + */ + public function historicTradesV2(): HistoricTradesV2 + { + return new HistoricTradesV2($this->apiKey); + } + + /** + * @return HistoricQuotes + */ + public function historicQuotes(): HistoricQuotes + { + return new HistoricQuotes($this->apiKey); + } + + /** + * @return HistoricQuotesV2 + */ + public function historicQuotesV2(): HistoricQuotesV2 + { + return new HistoricQuotesV2($this->apiKey); + } + + /** + * @return LastTradeForSymbol + */ + public function lastTradeForSymbol(): LastTradeForSymbol + { + return new LastTradeForSymbol($this->apiKey); + } + + /** + * @return LastQuoteForSymbol + */ + public function lastQuoteForSymbol(): LastQuoteForSymbol + { + return new LastQuoteForSymbol($this->apiKey); + } + + /** + * @return DailyOpenClose + */ + public function dailyOpenClose(): DailyOpenClose + { + return new DailyOpenClose($this->apiKey); + } + + /** + * @return ConditionMappings + */ + public function conditionMappings(): ConditionMappings + { + return new ConditionMappings($this->apiKey); + } + + /** + * @return SnapshotAllTickers + */ + public function snapshotAllTickers(): SnapshotAllTickers + { + return new SnapshotAllTickers($this->apiKey); + } + + /** + * @return SnapshotSingleTicker + */ + public function snapshotSingleTicker(): SnapshotSingleTicker + { + return new SnapshotSingleTicker($this->apiKey); + } + + /** + * @return SnapshotGainersLosers + */ + public function snapshotGainersLosers(): SnapshotGainersLosers + { + return new SnapshotGainersLosers($this->apiKey); + } + + /** + * @return PreviousClose + */ + public function previousClose(): PreviousClose + { + return new PreviousClose($this->apiKey); + } + + /** + * @return Aggregates + */ + public function aggregates(): Aggregates + { + return new Aggregates($this->apiKey); + } + + /** + * @return GroupedDaily + */ + public function groupedDaily(): GroupedDaily + { + return new GroupedDaily($this->apiKey); + } +} diff --git a/src/Websockets/WebsocketResource.php b/src/Websockets/WebsocketResource.php new file mode 100644 index 0000000..10e8c13 --- /dev/null +++ b/src/Websockets/WebsocketResource.php @@ -0,0 +1,65 @@ +apiKey = $apiKey; + $this->topic = $topic; + } + + /** + * @param $subscriptions + * @param $onMessageCallback + */ + public function connect($subscriptions, $onMessageCallback) + { + \Amp\Loop::run( + function () use ($onMessageCallback, $subscriptions) { + /** + * @var Websocket\Connection $connection + */ + $connection = yield Websocket\connect(self::SOCKET_URI . '/' . $this->topic); + yield $connection->send('{"action":"auth", "params":"' . $this->apiKey . '"}'); + yield $connection->send( + json_encode( + [ + "action" => "subscribe", + "params" => $subscriptions, + ] + ) + ); + + /** + * @var Websocket\Message $message + */ + while ($message = yield $connection->receive()) { + $payload = yield $message->buffer(); + $onMessageCallback(json_decode($payload)); + } + } + ); + } +} diff --git a/src/Websockets/Websockets.php b/src/Websockets/Websockets.php new file mode 100644 index 0000000..6f96155 --- /dev/null +++ b/src/Websockets/Websockets.php @@ -0,0 +1,67 @@ +apiKey = $apiKey; + + $this->crypto = new WebsocketResource('crypto', $apiKey); + $this->forex = new WebsocketResource('forex', $apiKey); + $this->stocks = new WebsocketResource('stocks', $apiKey); + } + + /** + * @return WebsocketResource + */ + public function crypto(): WebsocketResource + { + return new WebsocketResource('crypto', $this->apiKey); + } + + /** + * @return WebsocketResource + */ + public function forex(): WebsocketResource + { + return new WebsocketResource('forex', $this->apiKey); + } + + /** + * @return WebsocketResource + */ + public function stocks(): WebsocketResource + { + return new WebsocketResource('stocks', $this->apiKey); + } +} diff --git a/src/rest/Rest.php b/src/rest/Rest.php deleted file mode 100644 index 4299fad..0000000 --- a/src/rest/Rest.php +++ /dev/null @@ -1,26 +0,0 @@ -reference = new Reference($apiKey); - $this->stocks = new Stocks($apiKey); - $this->forex = new Forex($apiKey); - $this->crypto = new Crypto($apiKey); - } -} \ No newline at end of file diff --git a/src/rest/RestResource.php b/src/rest/RestResource.php deleted file mode 100644 index eabfd67..0000000 --- a/src/rest/RestResource.php +++ /dev/null @@ -1,50 +0,0 @@ -api_key = $apiKey; - $this->httpClient = new \GuzzleHttp\Client(); - } - - protected function _get($route, $params = []){ - $enhancedParams = array_merge( - [ - 'apiKey' => $this->api_key, - ], - array_merge( - $this->defaultParams, - $params - ) - ); - - $route = $this->API_URL.$route; - $response = $this->httpClient->get($route, [ - 'query' => $enhancedParams - ]); - - $bodyString = $response->getBody()->getContents(); - $json = json_decode($bodyString, true); - return $this->mapper($json); - } - - protected function mapper($response) { - return $response; - } -} \ No newline at end of file diff --git a/src/rest/common/Mappers.php b/src/rest/common/Mappers.php deleted file mode 100644 index ec0fd73..0000000 --- a/src/rest/common/Mappers.php +++ /dev/null @@ -1,89 +0,0 @@ -_get('/v2/aggs/ticker/'.$tickerSymbol.'/range/'.$multiplier.'/'.$timespan.'/'.$from.'/'.$to, $params); - } - - protected function mapper($response) - { - $response['results'] = array_map(function ($result) { - return Mappers::snapshotAggV2($result); - }, $response['results']); - return $response; - } -} \ No newline at end of file diff --git a/src/rest/crypto/Crypto.php b/src/rest/crypto/Crypto.php deleted file mode 100644 index d7d8a0f..0000000 --- a/src/rest/crypto/Crypto.php +++ /dev/null @@ -1,31 +0,0 @@ -previousClose = new PreviousClose($apiKey); - $this->groupedDaily = new GroupedDaily($apiKey); - $this->aggregates = new Aggregates($apiKey); - $this->cryptoExchanges = new CryptoExchanges($apiKey); - $this->lastTradeForCryptoPair = new LastTradeForCryptoPair($apiKey); - $this->dailyOpenClose = new DailyOpenClose($apiKey); - $this->historicCryptoTrade = new HistoricCryptoTrade($apiKey); - $this->snapshotAllTickers = new SnapshotAllTickers($apiKey); - $this->snapshotGainersLosers = new SnapshotGainersLosers($apiKey); - $this->snapshotSingleTicker = new SnapshotSingleTicker($apiKey); - $this->snapshotSingleTickerFullBook = new SnapshotSingleTickerFullBook($apiKey); - } -} \ No newline at end of file diff --git a/src/rest/crypto/CryptoExchanges.php b/src/rest/crypto/CryptoExchanges.php deleted file mode 100644 index 3dcc525..0000000 --- a/src/rest/crypto/CryptoExchanges.php +++ /dev/null @@ -1,11 +0,0 @@ -_get($this->route); - } -} \ No newline at end of file diff --git a/src/rest/crypto/DailyOpenClose.php b/src/rest/crypto/DailyOpenClose.php deleted file mode 100644 index 25c1533..0000000 --- a/src/rest/crypto/DailyOpenClose.php +++ /dev/null @@ -1,22 +0,0 @@ -_get('/v1/open-close/crypto/'.$from.'/'.$to.'/'.$date); - } - - protected function mapper($response) - { - if (array_key_exists('openTrades', $response)) { - $response['openTrades'] = array_map(Mappers::cryptoTick, $response['openTrades']); - } - if (array_key_exists('closingTrades', $response)) { - $response['closingTrades'] = array_map(Mappers::cryptoTick, $response['closingTrades']); - } - return $response; - } -} \ No newline at end of file diff --git a/src/rest/crypto/GroupedDaily.php b/src/rest/crypto/GroupedDaily.php deleted file mode 100644 index 157ddc1..0000000 --- a/src/rest/crypto/GroupedDaily.php +++ /dev/null @@ -1,19 +0,0 @@ -_get('/v2/aggs/grouped/locale/'.$locale.'/market/'.$market.'/'.$date, $params); - } - - protected function mapper($response) - { - $response['results'] = array_map(function ($result) { - return Mappers::snapshotAggV2($result); - }, $response['results']); - return $response; - } -} \ No newline at end of file diff --git a/src/rest/crypto/HistoricCryptoTrade.php b/src/rest/crypto/HistoricCryptoTrade.php deleted file mode 100644 index 89cc58f..0000000 --- a/src/rest/crypto/HistoricCryptoTrade.php +++ /dev/null @@ -1,23 +0,0 @@ - 100, - ]; - - public function get($from, $to, $date, $params = []){ - return $this->_get('/v1/historic/crypto/'.$from.'/'.$to.'/'.$date, $params); - } - - protected function mapper($response) - { - $response['ticks'] = array_map(function($tick) { - return Mappers::cryptoTick($tick); - }, $response['ticks']); - return $response; - } -} \ No newline at end of file diff --git a/src/rest/crypto/LastTradeForCryptoPair.php b/src/rest/crypto/LastTradeForCryptoPair.php deleted file mode 100644 index 3b0fd1d..0000000 --- a/src/rest/crypto/LastTradeForCryptoPair.php +++ /dev/null @@ -1,10 +0,0 @@ -_get('/v1/last/crypto/'.$from.'/'.$to); - } -} \ No newline at end of file diff --git a/src/rest/crypto/PreviousClose.php b/src/rest/crypto/PreviousClose.php deleted file mode 100644 index 15acced..0000000 --- a/src/rest/crypto/PreviousClose.php +++ /dev/null @@ -1,19 +0,0 @@ -_get('/v2/aggs/ticker/'.$tickerSymbol.'/prev', $params); - } - - protected function mapper($response) - { - $response['results'] = array_map(function ($result) { - return Mappers::snapshotAggV2($result); - }, $response['results']); - return $response; - } -} \ No newline at end of file diff --git a/src/rest/crypto/SnapshotAllTickers.php b/src/rest/crypto/SnapshotAllTickers.php deleted file mode 100644 index 4a89055..0000000 --- a/src/rest/crypto/SnapshotAllTickers.php +++ /dev/null @@ -1,19 +0,0 @@ -_get('/v2/snapshot/locale/global/markets/crypto/tickers'); - } - - protected function mapper($response) - { - $response['tickers'] = array_map(function ($ticker) { - return Mappers::snapshotCryptoTicker($ticker); - }, $response['tickers']); - return $response; - } -} \ No newline at end of file diff --git a/src/rest/crypto/SnapshotGainersLosers.php b/src/rest/crypto/SnapshotGainersLosers.php deleted file mode 100644 index ca5d0ff..0000000 --- a/src/rest/crypto/SnapshotGainersLosers.php +++ /dev/null @@ -1,19 +0,0 @@ -_get('/v2/snapshot/locale/global/markets/crypto/'.$direction); - } - - protected function mapper($response) - { - $response['tickers'] = array_map(function ($ticker) { - return Mappers::snapshotTicker($ticker); - }, $response['tickers']); - return $response; - } -} \ No newline at end of file diff --git a/src/rest/crypto/SnapshotSingleTicker.php b/src/rest/crypto/SnapshotSingleTicker.php deleted file mode 100644 index 67ea22f..0000000 --- a/src/rest/crypto/SnapshotSingleTicker.php +++ /dev/null @@ -1,17 +0,0 @@ -_get('/v2/snapshot/locale/global/markets/crypto/tickers/'.$tickerSymbol); - } - - protected function mapper($response) - { - $response['ticker'] = Mappers::snapshotCryptoTicker($response['ticker']); - return $response; - } -} \ No newline at end of file diff --git a/src/rest/crypto/SnapshotSingleTickerFullBook.php b/src/rest/crypto/SnapshotSingleTickerFullBook.php deleted file mode 100644 index 8fff940..0000000 --- a/src/rest/crypto/SnapshotSingleTickerFullBook.php +++ /dev/null @@ -1,26 +0,0 @@ -_get('/v2/snapshot/locale/global/markets/crypto/tickers/'.$tickerSymbol.'/book'); - } - - protected function mapper($response) - { - if(array_key_exists('asks', $response['data'])) { - $response['data']['asks'] = array_merge(function($ask) { - return Mappers::cryptoSnapshotBookItem($ask); - }, $response['data']['asks']); - } - if (array_key_exists('bids', $response['data'])) { - $response['data']['bids'] = array_merge(function($bid) { - return Mappers::cryptoSnapshotBookItem($bid); - }, $response['data']['bids']); - } - return $response; - } -} \ No newline at end of file diff --git a/src/rest/forex/Aggregates.php b/src/rest/forex/Aggregates.php deleted file mode 100644 index c56e4c6..0000000 --- a/src/rest/forex/Aggregates.php +++ /dev/null @@ -1,19 +0,0 @@ -_get('/v2/aggs/ticker/'.$tickerSymbol.'/range/'.$multiplier.'/'.$timespan.'/'.$from.'/'.$to, $params); - } - - protected function mapper($response) - { - $response['results'] = array_map(function ($result) { - return Mappers::snapshotAggV2($result); - }, $response['results']); - return $response; - } -} \ No newline at end of file diff --git a/src/rest/forex/Forex.php b/src/rest/forex/Forex.php deleted file mode 100644 index a4edac7..0000000 --- a/src/rest/forex/Forex.php +++ /dev/null @@ -1,25 +0,0 @@ -groupedDaily = new GroupedDaily($apiKey); - $this->aggregates = new Aggregates($apiKey); - $this->previousClose = new PreviousClose($apiKey); - $this->historicForexTick = new HistoricForexTick($apiKey); - $this->realTimeCurrencyConversion = new RealTimeCurrencyConversion($apiKey); - $this->lastQuoteForCurrencyPair = new LastQuoteForCurrencyPair($apiKey); - $this->snapshotAllTickers = new SnapshotAllTickers($apiKey); - $this->snapshotGainersLosers = new SnapshotGainersLosers($apiKey); - } -} \ No newline at end of file diff --git a/src/rest/forex/GroupedDaily.php b/src/rest/forex/GroupedDaily.php deleted file mode 100644 index 1d9c3d9..0000000 --- a/src/rest/forex/GroupedDaily.php +++ /dev/null @@ -1,19 +0,0 @@ -_get('/v2/aggs/grouped/locale/'.$locale.'/market/'.$market.'/'.$date, $params); - } - - protected function mapper($response) - { - $response['results'] = array_map(function ($result) { - return Mappers::snapshotAggV2($result); - }, $response['results']); - return $response; - } -} \ No newline at end of file diff --git a/src/rest/forex/HistoricForexTick.php b/src/rest/forex/HistoricForexTick.php deleted file mode 100644 index bb3495c..0000000 --- a/src/rest/forex/HistoricForexTick.php +++ /dev/null @@ -1,14 +0,0 @@ - 100, - ]; - - public function get($from, $to, $date, $params = []) { - return $this->_get('/v1/historic/forex/'.$from.'/'.$to.'/'.$date, $params); - } -} \ No newline at end of file diff --git a/src/rest/forex/LastQuoteForCurrencyPair.php b/src/rest/forex/LastQuoteForCurrencyPair.php deleted file mode 100644 index 84e5686..0000000 --- a/src/rest/forex/LastQuoteForCurrencyPair.php +++ /dev/null @@ -1,10 +0,0 @@ -_get('/v1/last_quote/currencies/'.$from.'/'.$to); - } -} \ No newline at end of file diff --git a/src/rest/forex/PreviousClose.php b/src/rest/forex/PreviousClose.php deleted file mode 100644 index 9f84325..0000000 --- a/src/rest/forex/PreviousClose.php +++ /dev/null @@ -1,19 +0,0 @@ -_get('/v2/aggs/ticker/'.$tickerSymbol.'/prev', $params); - } - - protected function mapper($response) - { - $response['results'] = array_map(function ($result) { - return Mappers::snapshotAggV2($result); - }, $response['results']); - return $response; - } -} \ No newline at end of file diff --git a/src/rest/forex/RealTimeCurrencyConversion.php b/src/rest/forex/RealTimeCurrencyConversion.php deleted file mode 100644 index a8b5420..0000000 --- a/src/rest/forex/RealTimeCurrencyConversion.php +++ /dev/null @@ -1,15 +0,0 @@ - 100, - 'precision' => 2, - ]; - - public function get($from, $to, $params = []) { - return $this->_get('/v1/conversion/'.$from.'/'.$to, $params); - } -} \ No newline at end of file diff --git a/src/rest/forex/SnapshotAllTickers.php b/src/rest/forex/SnapshotAllTickers.php deleted file mode 100644 index 8085961..0000000 --- a/src/rest/forex/SnapshotAllTickers.php +++ /dev/null @@ -1,19 +0,0 @@ -_get('/v2/snapshot/locale/global/markets/forex/tickers'); - } - - protected function mapper($response) - { - $response['tickers'] = array_map(function ($ticker) { - return Mappers::snapshotTicker($ticker); - }, $response['tickers']); - return $response; - } -} \ No newline at end of file diff --git a/src/rest/forex/SnapshotGainersLosers.php b/src/rest/forex/SnapshotGainersLosers.php deleted file mode 100644 index d7ef210..0000000 --- a/src/rest/forex/SnapshotGainersLosers.php +++ /dev/null @@ -1,19 +0,0 @@ -_get('/v2/snapshot/locale/global/markets/forex/'.$direction); - } - - protected function mapper($response) - { - $response['tickers'] = array_map(function ($ticker) { - return Mappers::snapshotTicker($ticker); - }, $response['tickers']); - return $response; - } -} \ No newline at end of file diff --git a/src/rest/reference/Locales.php b/src/rest/reference/Locales.php deleted file mode 100644 index c7fffa5..0000000 --- a/src/rest/reference/Locales.php +++ /dev/null @@ -1,16 +0,0 @@ -_get($this->route); - } -} \ No newline at end of file diff --git a/src/rest/reference/MarketHolidays.php b/src/rest/reference/MarketHolidays.php deleted file mode 100644 index 38cbb4e..0000000 --- a/src/rest/reference/MarketHolidays.php +++ /dev/null @@ -1,16 +0,0 @@ -_get($this->route); - } -} \ No newline at end of file diff --git a/src/rest/reference/MarketStatus.php b/src/rest/reference/MarketStatus.php deleted file mode 100644 index 039a235..0000000 --- a/src/rest/reference/MarketStatus.php +++ /dev/null @@ -1,16 +0,0 @@ -_get($this->route); - } -} \ No newline at end of file diff --git a/src/rest/reference/Markets.php b/src/rest/reference/Markets.php deleted file mode 100644 index bd42e60..0000000 --- a/src/rest/reference/Markets.php +++ /dev/null @@ -1,16 +0,0 @@ -_get($this->route); - } -} \ No newline at end of file diff --git a/src/rest/reference/Reference.php b/src/rest/reference/Reference.php deleted file mode 100644 index 1fbc5fb..0000000 --- a/src/rest/reference/Reference.php +++ /dev/null @@ -1,39 +0,0 @@ -tickers = new Tickers($apiKey); - $this->tickerTypes = new TickerTypes($apiKey); - $this->tickerDetails = new TickerDetails($apiKey); - $this->tickerNews = new TickerNews($apiKey); - $this->markets = new Markets($apiKey); - $this->locales = new Locales($apiKey); - $this->stockSplits = new StockSplits($apiKey); - $this->stockDividends = new StockDividends($apiKey); - $this->stockFinancials = new StockFinancials($apiKey); - $this->marketStatus = new MarketStatus($apiKey); - $this->marketHolidays = new MarketHolidays($apiKey); - } -} \ No newline at end of file diff --git a/src/rest/reference/StockDividends.php b/src/rest/reference/StockDividends.php deleted file mode 100644 index 09bcca4..0000000 --- a/src/rest/reference/StockDividends.php +++ /dev/null @@ -1,18 +0,0 @@ -_get('/v2/reference/dividends/'.$tickerSymbol); - } -} \ No newline at end of file diff --git a/src/rest/reference/StockFinancials.php b/src/rest/reference/StockFinancials.php deleted file mode 100644 index 0a37860..0000000 --- a/src/rest/reference/StockFinancials.php +++ /dev/null @@ -1,19 +0,0 @@ - 5, - ]; - - /** - * @param $tickerSymbol - * @param $params - * @return mixed - */ - public function get($tickerSymbol, $params = []) { - return $this->_get('/v2/reference/financials/'.$tickerSymbol, $params); - } -} \ No newline at end of file diff --git a/src/rest/reference/StockSplits.php b/src/rest/reference/StockSplits.php deleted file mode 100644 index e812b36..0000000 --- a/src/rest/reference/StockSplits.php +++ /dev/null @@ -1,18 +0,0 @@ -_get('/v2/reference/splits/'.$tickerSymbol); - } -} \ No newline at end of file diff --git a/src/rest/reference/TickerDetails.php b/src/rest/reference/TickerDetails.php deleted file mode 100644 index f93ea11..0000000 --- a/src/rest/reference/TickerDetails.php +++ /dev/null @@ -1,24 +0,0 @@ -_get('/v1/meta/symbols/'.$tickerSymbol.'/company'); - } - - protected function mapper($response) { - $response['legalEntityIdentifier'] = $response['lei']; - $response['standardIndustryClassification'] = $response['sic']; - return $response; - } -} \ No newline at end of file diff --git a/src/rest/reference/TickerNews.php b/src/rest/reference/TickerNews.php deleted file mode 100644 index b7ef1ce..0000000 --- a/src/rest/reference/TickerNews.php +++ /dev/null @@ -1,24 +0,0 @@ - 50, - 'page' => 1, - ]; - - /** - * @param $tickerSymbol - * @param $params - * @return mixed - */ - public function get($tickerSymbol, $params = []) { - return $this->_get('/v1/meta/symbols/'.$tickerSymbol.'/news', $params); - } -} \ No newline at end of file diff --git a/src/rest/reference/TickerTypes.php b/src/rest/reference/TickerTypes.php deleted file mode 100644 index affdb81..0000000 --- a/src/rest/reference/TickerTypes.php +++ /dev/null @@ -1,16 +0,0 @@ -_get($this->route); - } -} \ No newline at end of file diff --git a/src/rest/stocks/Aggregates.php b/src/rest/stocks/Aggregates.php deleted file mode 100644 index c6ac15a..0000000 --- a/src/rest/stocks/Aggregates.php +++ /dev/null @@ -1,19 +0,0 @@ -_get('/v2/aggs/ticker/'.$tickerSymbol.'/range/'.$multiplier.'/'.$timespan.'/'.$from.'/'.$to, $params); - } - - protected function mapper($response) - { - $response['results'] = array_map(function ($result) { - return Mappers::snapshotAggV2($result); - }, $response['results']); - return $response; - } -} \ No newline at end of file diff --git a/src/rest/stocks/ConditionMappings.php b/src/rest/stocks/ConditionMappings.php deleted file mode 100644 index 7a23e9a..0000000 --- a/src/rest/stocks/ConditionMappings.php +++ /dev/null @@ -1,10 +0,0 @@ -_get('/v1/meta/conditions/'.$tickTypes); - } -} \ No newline at end of file diff --git a/src/rest/stocks/DailyOpenClose.php b/src/rest/stocks/DailyOpenClose.php deleted file mode 100644 index 8d4f65f..0000000 --- a/src/rest/stocks/DailyOpenClose.php +++ /dev/null @@ -1,10 +0,0 @@ -_get('/v1/open-close/'.$tickerSymbol.'/'.$date); - } -} \ No newline at end of file diff --git a/src/rest/stocks/Exchanges.php b/src/rest/stocks/Exchanges.php deleted file mode 100644 index 489c082..0000000 --- a/src/rest/stocks/Exchanges.php +++ /dev/null @@ -1,12 +0,0 @@ -_get($this->route); - } -} \ No newline at end of file diff --git a/src/rest/stocks/GroupedDaily.php b/src/rest/stocks/GroupedDaily.php deleted file mode 100644 index 14e43d1..0000000 --- a/src/rest/stocks/GroupedDaily.php +++ /dev/null @@ -1,19 +0,0 @@ -_get('/v2/aggs/grouped/locale/'.$locale.'/market/'.$market.'/'.$date, $params); - } - - protected function mapper($response) - { - $response['results'] = array_map(function ($result) { - return Mappers::snapshotAggV2($result); - }, $response['results']); - return $response; - } -} \ No newline at end of file diff --git a/src/rest/stocks/HistoricQuotes.php b/src/rest/stocks/HistoricQuotes.php deleted file mode 100644 index b0559ad..0000000 --- a/src/rest/stocks/HistoricQuotes.php +++ /dev/null @@ -1,29 +0,0 @@ - 100 - ]; - public function get($tickerSymbol, $date) { - return $this->_get('/v1/historic/quotes/'.$tickerSymbol.'/'.$date); - } - - protected function mapper($response) - { - $response['ticks'] = array_map(function ($tick) { - $tick['condition'] = $tick['c']; - $tick['bidExchange'] = $tick['bE']; - $tick['askExchange'] = $tick['aE']; - $tick['askPrice'] = $tick['aP']; - $tick['buyPrice'] = $tick['bP']; - $tick['bidSize'] = $tick['bS']; - $tick['askSize'] = $tick['aS']; - $tick['timestamp'] = $tick['t']; - return $tick; - }, $response['ticks']); - return $response; - } -} \ No newline at end of file diff --git a/src/rest/stocks/HistoricQuotesV2.php b/src/rest/stocks/HistoricQuotesV2.php deleted file mode 100644 index 18c15bc..0000000 --- a/src/rest/stocks/HistoricQuotesV2.php +++ /dev/null @@ -1,37 +0,0 @@ - 100 - ]; - public function get($tickerSymbol, $date) { - return $this->_get('/v2/ticks/stocks/nbbo/'.$tickerSymbol.'/'.$date); - } - - protected function mapper($response) - { - if ($response['results']) { - $response['results'] = array_map(function ($result) { - $result['ticker'] = $result['T']; - $result['SIPTimestamp'] = $result['t']; - $result['participantExchangeTimestamp'] = $result['y']; - $result['tradeReportingFacilityTimestamp'] = $result['f']; - $result['sequenceNumber'] = $result['q']; - $result['conditions'] = $result['c']; - $result['indicators'] = $result['i']; - $result['bidPrice'] = $result['p']; - $result['bidExchangeId'] = $result['x']; - $result['bidSize'] = $result['s']; - $result['askPrice'] = $result['p']; - $result['askExchangeId'] = $result['X']; - $result['askSize'] = $result['S']; - $result['tapeWhereTradeOccured'] = $result['z']; - return $result; - }, $response['results']); - } - return $response; - } -} \ No newline at end of file diff --git a/src/rest/stocks/HistoricTrades.php b/src/rest/stocks/HistoricTrades.php deleted file mode 100644 index fb360fd..0000000 --- a/src/rest/stocks/HistoricTrades.php +++ /dev/null @@ -1,29 +0,0 @@ - 100 - ]; - public function get($tickerSymbol, $date) { - return $this->_get('/v1/historic/trades/'.$tickerSymbol.'/'.$date); - } - - protected function mapper($response) - { - $response['ticks'] = array_map(function ($tick) { - $tick['condition1'] = $tick['c1']; - $tick['condition2'] = $tick['c2']; - $tick['condition3'] = $tick['c3']; - $tick['condition4'] = $tick['c4']; - $tick['exchange'] = $tick['e']; - $tick['price'] = $tick['p']; - $tick['size'] = $tick['s']; - $tick['timestamp'] = $tick['t']; - return $tick; - }, $response['ticks']); - return $response; - } -} \ No newline at end of file diff --git a/src/rest/stocks/HistoricTradesV2.php b/src/rest/stocks/HistoricTradesV2.php deleted file mode 100644 index b0c9f8f..0000000 --- a/src/rest/stocks/HistoricTradesV2.php +++ /dev/null @@ -1,32 +0,0 @@ - 100 - ]; - public function get($tickerSymbol, $date) { - return $this->_get('/v2/ticks/stocks/trades/'.$tickerSymbol.'/'.$date); - } - - protected function mapper($response) - { - $response['ticks'] = array_map(function ($tick) { - $tick['ticker'] = $tick['T']; - $tick['SIPTimestamp'] = $tick['t']; - $tick['participantExchangeTimestamp'] = $tick['y']; - $tick['tradeReportingFacilityTimestamp'] = $tick['y']; - $tick['sequenceNumber'] = $tick['q']; - $tick['tradeId'] = $tick['i']; - $tick['exchange'] = $tick['x']; - $tick['size'] = $tick['s']; - $tick['conditions'] = $tick['c']; - $tick['price'] = $tick['p']; - $tick['tapeWhereTheTradeOccured'] = $tick['z']; - return $tick; - }, $response['ticks']); - return $response; - } -} \ No newline at end of file diff --git a/src/rest/stocks/LastQuoteForSymbol.php b/src/rest/stocks/LastQuoteForSymbol.php deleted file mode 100644 index b63f759..0000000 --- a/src/rest/stocks/LastQuoteForSymbol.php +++ /dev/null @@ -1,10 +0,0 @@ -_get('/v1/last_quote/stocks/'.$tickerSymbol); - } -} \ No newline at end of file diff --git a/src/rest/stocks/LastTradeForSymbol.php b/src/rest/stocks/LastTradeForSymbol.php deleted file mode 100644 index 04a707f..0000000 --- a/src/rest/stocks/LastTradeForSymbol.php +++ /dev/null @@ -1,10 +0,0 @@ -_get('/v1/last/stocks/'.$tickerSymbol); - } -} \ No newline at end of file diff --git a/src/rest/stocks/PreviousClose.php b/src/rest/stocks/PreviousClose.php deleted file mode 100644 index 4fe6cf9..0000000 --- a/src/rest/stocks/PreviousClose.php +++ /dev/null @@ -1,19 +0,0 @@ -_get('/v2/aggs/ticker/'.$tickerSymbol.'/prev', $params); - } - - protected function mapper($response) - { - $response['results'] = array_map(function ($result) { - return Mappers::snapshotAggV2($result); - }, $response['results']); - return $response; - } -} \ No newline at end of file diff --git a/src/rest/stocks/SnapshotAllTickers.php b/src/rest/stocks/SnapshotAllTickers.php deleted file mode 100644 index dd73c0b..0000000 --- a/src/rest/stocks/SnapshotAllTickers.php +++ /dev/null @@ -1,19 +0,0 @@ -_get('/v2/snapshot/locale/us/markets/stocks/tickers'); - } - - protected function mapper($response) - { - $response['tickers'] = array_map(function ($ticker) { - return Mappers::snapshotTicker($ticker); - }, $response['tickers']); - return $response; - } -} \ No newline at end of file diff --git a/src/rest/stocks/SnapshotGainersLosers.php b/src/rest/stocks/SnapshotGainersLosers.php deleted file mode 100644 index 1b16106..0000000 --- a/src/rest/stocks/SnapshotGainersLosers.php +++ /dev/null @@ -1,19 +0,0 @@ -_get('/v2/snapshot/locale/us/markets/stocks/'.$direction); - } - - protected function mapper($response) - { - $response['tickers'] = array_map(function ($ticker) { - return Mappers::snapshotTicker($ticker); - }, $response['tickers']); - return $response; - } -} \ No newline at end of file diff --git a/src/rest/stocks/SnapshotSingleTicker.php b/src/rest/stocks/SnapshotSingleTicker.php deleted file mode 100644 index 99b1b0c..0000000 --- a/src/rest/stocks/SnapshotSingleTicker.php +++ /dev/null @@ -1,17 +0,0 @@ -_get('/v2/snapshot/locale/us/markets/stocks/tickers/'.$tickerSymbol); - } - - protected function mapper($response) - { - $response['ticker'] = Mappers::snapshotTicker($response['ticker']); - return $response; - } -} \ No newline at end of file diff --git a/src/rest/stocks/Stocks.php b/src/rest/stocks/Stocks.php deleted file mode 100644 index e60e66c..0000000 --- a/src/rest/stocks/Stocks.php +++ /dev/null @@ -1,41 +0,0 @@ -exchanges = new Exchanges($apiKey); - $this->historicTrades = new HistoricTrades($apiKey); - $this->historicTradesV2 = new HistoricTradesV2($apiKey); - $this->historicQuotes = new HistoricQuotes($apiKey); - $this->historicQuotesV2 = new HistoricQuotesV2($apiKey); - $this->lastTradeForSymbol = new LastTradeForSymbol($apiKey); - $this->lastQuoteForSymbol = new LastQuoteForSymbol($apiKey); - $this->dailyOpenClose = new DailyOpenClose($apiKey); - $this->conditionMappings = new ConditionMappings($apiKey); - $this->snapshotAllTickers = new SnapshotAllTickers($apiKey); - $this->snapshotSingleTicker = new SnapshotSingleTicker($apiKey); - $this->snapshotGainersLosers = new SnapshotGainersLosers($apiKey); - $this->previousClose = new PreviousClose($apiKey); - $this->aggregates = new Aggregates($apiKey); - $this->groupedDaily = new GroupedDaily($apiKey); - } -} \ No newline at end of file diff --git a/src/websocket/WebsocketResource.php b/src/websocket/WebsocketResource.php deleted file mode 100644 index f3efd68..0000000 --- a/src/websocket/WebsocketResource.php +++ /dev/null @@ -1,32 +0,0 @@ -apiKey = $apiKey; - $this->SOCKET_URI = 'wss://socket.polygon.io:443/'.$topic; - } - - public function connect($subscriptions, $onMessageCallback) { - \Amp\Loop::run(function () use ($onMessageCallback, $subscriptions) { - /** @var Websocket\Connection $connection */ - $connection = yield Websocket\connect($this->SOCKET_URI); - yield $connection->send('{"action":"auth", "params":"'.$this->apiKey.'"}'); - yield $connection->send(json_encode([ - "action" => "subscribe", - "params" => $subscriptions, - ])); - /** @var Websocket\Message $message */ - while ($message = yield $connection->receive()) { - $payload = yield $message->buffer(); - $onMessageCallback(json_decode($payload)); - } - }); - } -} \ No newline at end of file diff --git a/src/websocket/Websockets.php b/src/websocket/Websockets.php deleted file mode 100644 index 7add795..0000000 --- a/src/websocket/Websockets.php +++ /dev/null @@ -1,15 +0,0 @@ -crypto = new WebsocketResource('crypto', $apiKey); - $this->forex = new WebsocketResource('forex', $apiKey); - $this->stocks = new WebsocketResource('stocks', $apiKey); - } -} diff --git a/tests/Helpers/MocksHttp.php b/tests/Helpers/MocksHttp.php new file mode 100644 index 0000000..28e4d12 --- /dev/null +++ b/tests/Helpers/MocksHttp.php @@ -0,0 +1,35 @@ +push($history); + + return new Client(['handler' => $handler]); + } + + private function assertPath($requests, $path) + { + $this->assertCount(1, $requests); + $this->assertEquals($path, $requests[0]['request']->getUri()->getPath()); + } +} diff --git a/tests/Rest/Common/MappersTest.php b/tests/Rest/Common/MappersTest.php new file mode 100644 index 0000000..b8b82cb --- /dev/null +++ b/tests/Rest/Common/MappersTest.php @@ -0,0 +1,426 @@ + 'dummyC', + 'bE' => 'dummyBE', + 'aE' => 'dummyAE', + 'aP' => 'dummyAP', + 'bP' => 'dummyBP', + 'bS' => 'dummyBS', + 'aS' => 'dummyAS', + 't' => 'dummyT', + ]; + + $expectedReturn = [ + 'c' => 'dummyC', + 'bE' => 'dummyBE', + 'aE' => 'dummyAE', + 'aP' => 'dummyAP', + 'bP' => 'dummyBP', + 'bS' => 'dummyBS', + 'aS' => 'dummyAS', + 't' => 'dummyT', + 'condition' => 'dummyC', + 'bidExchange' => 'dummyBE', + 'askExchange' => 'dummyAE', + 'askPrice' => 'dummyAP', + 'buyPrice' => 'dummyBP', + 'bidSize' => 'dummyBS', + 'askSize' => 'dummyAS', + 'timestamp' => 'dummyT', + ]; + + $actualReturn = Mappers::quoteV1($tickData); + + $this->assertEquals($expectedReturn, $actualReturn); + } + + public function testSnapshotQuote() + { + $tickData = [ + 'p' => 'dummyBidPrice', + 's' => 'dummyBidSize', + 'P' => 'dummyAskPrice', + 'S' => 'dummyAskSize', + 't' => 'dummyTimestamp', + ]; + + $expectedReturn = [ + 'p' => 'dummyBidPrice', + 's' => 'dummyBidSize', + 'P' => 'dummyAskPrice', + 'S' => 'dummyAskSize', + 't' => 'dummyTimestamp', + 'bidPrice' => 'dummyBidPrice', + 'bidSize' => 'dummyBidSize', + 'askPrice' => 'dummyAskPrice', + 'askSize' => 'dummyAskSize', + 'lastUpdateTimestamp' => 'dummyTimestamp', + ]; + + $actualReturn = Mappers::snapshotQuote($tickData); + + $this->assertEquals($expectedReturn, $actualReturn); + } + + public function testTradeV1() + { + $tickData = [ + 'c1' => 'dummyCondition1', + 'c2' => 'dummyCondition2', + 'c3' => 'dummyCondition3', + 'c4' => 'dummyCondition4', + 'e' => 'dummyExchange', + 'p' => 'dummyPrice', + 's' => 'dummySize', + 't' => 'dummyTimestamp', + ]; + + $expectedReturn = [ + 'c1' => 'dummyCondition1', + 'c2' => 'dummyCondition2', + 'c3' => 'dummyCondition3', + 'c4' => 'dummyCondition4', + 'e' => 'dummyExchange', + 'p' => 'dummyPrice', + 's' => 'dummySize', + 't' => 'dummyTimestamp', + 'condition1' => 'dummyCondition1', + 'condition2' => 'dummyCondition2', + 'condition3' => 'dummyCondition3', + 'condition4' => 'dummyCondition4', + 'exchange' => 'dummyExchange', + 'price' => 'dummyPrice', + 'size' => 'dummySize', + 'timestamp' => 'dummyTimestamp', + ]; + + $actualReturn = Mappers::tradeV1($tickData); + + $this->assertEquals($expectedReturn, $actualReturn); + } + + public function testSnapshotAgg() + { + $tickData = [ + 'c' => 'dummyClose', + 'h' => 'dummyHigh', + 'l' => 'dummyLow', + 'o' => 'dummyOpen', + 'v' => 'dummyVolume', + ]; + + $expectedReturn = [ + 'c' => 'dummyClose', + 'h' => 'dummyHigh', + 'l' => 'dummyLow', + 'o' => 'dummyOpen', + 'v' => 'dummyVolume', + 'close' => 'dummyClose', + 'high' => 'dummyHigh', + 'low' => 'dummyLow', + 'open' => 'dummyOpen', + 'volume' => 'dummyVolume', + ]; + + $actualReturn = Mappers::snapshotAgg($tickData); + + $this->assertEquals($expectedReturn, $actualReturn); + } + + public function testSnapshotAggV2() + { + $tickData = [ + 'T' => 'dummyTickerSymbol', + 'v' => 'dummyVolume', + 'o' => 'dummyOpen', + 'c' => 'dummyClose', + 'h' => 'dummyHigh', + 'l' => 'dummyLow', + 't' => 'dummyTimestamp', + 'n' => 'dummyNumberOfItems', + ]; + + $expectedReturn = [ + 'T' => 'dummyTickerSymbol', + 'v' => 'dummyVolume', + 'o' => 'dummyOpen', + 'c' => 'dummyClose', + 'h' => 'dummyHigh', + 'l' => 'dummyLow', + 't' => 'dummyTimestamp', + 'n' => 'dummyNumberOfItems', + 'tickerSymbol' => 'dummyTickerSymbol', + 'volume' => 'dummyVolume', + 'open' => 'dummyOpen', + 'close' => 'dummyClose', + 'high' => 'dummyHigh', + 'low' => 'dummyLow', + 'timestamp' => 'dummyTimestamp', + 'numberOfItems' => 'dummyNumberOfItems', + ]; + + $actualReturn = Mappers::snapshotAggV2($tickData); + + $this->assertEquals($expectedReturn, $actualReturn); + } + + public function testCryptoTick() + { + $tickData = [ + 'p' => 'dummyPrice', + 's' => 'dummySize', + 'x' => 'dummyExchange', + 'c' => 'dummyConditions', + 't' => 'dummyTimestamp', + ]; + + $expectedReturn = [ + 'p' => 'dummyPrice', + 's' => 'dummySize', + 'x' => 'dummyExchange', + 'c' => 'dummyConditions', + 't' => 'dummyTimestamp', + 'price' => 'dummyPrice', + 'size' => 'dummySize', + 'exchange' => 'dummyExchange', + 'conditions' => 'dummyConditions', + 'timestamp' => 'dummyTimestamp', + ]; + + $actualReturn = Mappers::cryptoTick($tickData); + + $this->assertEquals($expectedReturn, $actualReturn); + } + + public function testCryptoSnapshotBookItem() + { + $tickData = [ + 'p' => 'dummyPrice', + ]; + + $expectedReturn = [ + 'p' => 'dummyPrice', + 'price' => 'dummyPrice', + ]; + + $actualReturn = Mappers::cryptoSnapshotBookItem($tickData); + + $this->assertEquals($expectedReturn, $actualReturn); + } + + public function testSnapshotTicker() + { + $tickData = [ + 'day' => [ + 'c' => 'dummyDayClose', + 'h' => 'dummyDayHigh', + 'l' => 'dummyDayLow', + 'o' => 'dummyDayOpen', + 'v' => 'dummyDayVolume', + ], + 'lastTrade' => [ + 'c1' => 'dummyLastTradeCondition1', + 'c2' => 'dummyLastTradeCondition2', + 'c3' => 'dummyLastTradeCondition3', + 'c4' => 'dummyLastTradeCondition4', + 'e' => 'dummyLastTradeExchange', + 'p' => 'dummyLastTradePrice', + 's' => 'dummyLastTradeSize', + 't' => 'dummyLastTradeTimestamp', + ], + 'lastQuote' => [ + 'p' => 'dummyLastQuoteBidPrice', + 's' => 'dummyLastQuoteBidSize', + 'P' => 'dummyLastQuoteAskPrice', + 'S' => 'dummyLastQuoteAskSize', + 't' => 'dummyLastQuoteTimestamp', + ], + 'min' => [ + 'c' => 'dummyMinClose', + 'h' => 'dummyMinHigh', + 'l' => 'dummyMinLow', + 'o' => 'dummyMinOpen', + 'v' => 'dummyMinVolume', + ], + 'prevDay' => [ + 'c' => 'dummyPrevDayClose', + 'h' => 'dummyPrevDayHigh', + 'l' => 'dummyPrevDayLow', + 'o' => 'dummyPrevDayOpen', + 'v' => 'dummyPrevDayVolume', + ], + ]; + + $expectedReturn = [ + 'day' => [ + 'c' => 'dummyDayClose', + 'h' => 'dummyDayHigh', + 'l' => 'dummyDayLow', + 'o' => 'dummyDayOpen', + 'v' => 'dummyDayVolume', + 'close' => 'dummyDayClose', + 'high' => 'dummyDayHigh', + 'low' => 'dummyDayLow', + 'open' => 'dummyDayOpen', + 'volume' => 'dummyDayVolume', + ], + 'lastTrade' => [ + 'c1' => 'dummyLastTradeCondition1', + 'c2' => 'dummyLastTradeCondition2', + 'c3' => 'dummyLastTradeCondition3', + 'c4' => 'dummyLastTradeCondition4', + 'e' => 'dummyLastTradeExchange', + 'p' => 'dummyLastTradePrice', + 's' => 'dummyLastTradeSize', + 't' => 'dummyLastTradeTimestamp', + 'condition1' => 'dummyLastTradeCondition1', + 'condition2' => 'dummyLastTradeCondition2', + 'condition3' => 'dummyLastTradeCondition3', + 'condition4' => 'dummyLastTradeCondition4', + 'exchange' => 'dummyLastTradeExchange', + 'price' => 'dummyLastTradePrice', + 'size' => 'dummyLastTradeSize', + 'timestamp' => 'dummyLastTradeTimestamp', + ], + 'lastQuote' => [ + 'p' => 'dummyLastQuoteBidPrice', + 's' => 'dummyLastQuoteBidSize', + 'P' => 'dummyLastQuoteAskPrice', + 'S' => 'dummyLastQuoteAskSize', + 't' => 'dummyLastQuoteTimestamp', + 'bidPrice' => 'dummyLastQuoteBidPrice', + 'bidSize' => 'dummyLastQuoteBidSize', + 'askPrice' => 'dummyLastQuoteAskPrice', + 'askSize' => 'dummyLastQuoteAskSize', + 'lastUpdateTimestamp' => 'dummyLastQuoteTimestamp', + ], + 'min' => [ + 'c' => 'dummyMinClose', + 'h' => 'dummyMinHigh', + 'l' => 'dummyMinLow', + 'o' => 'dummyMinOpen', + 'v' => 'dummyMinVolume', + 'close' => 'dummyMinClose', + 'high' => 'dummyMinHigh', + 'low' => 'dummyMinLow', + 'open' => 'dummyMinOpen', + 'volume' => 'dummyMinVolume', + ], + 'prevDay' => [ + 'c' => 'dummyPrevDayClose', + 'h' => 'dummyPrevDayHigh', + 'l' => 'dummyPrevDayLow', + 'o' => 'dummyPrevDayOpen', + 'v' => 'dummyPrevDayVolume', + 'close' => 'dummyPrevDayClose', + 'high' => 'dummyPrevDayHigh', + 'low' => 'dummyPrevDayLow', + 'open' => 'dummyPrevDayOpen', + 'volume' => 'dummyPrevDayVolume', + ], + ]; + + $actualReturn = Mappers::snapshotTicker($tickData); + + $this->assertEquals($expectedReturn, $actualReturn); + } + + public function testSnapshotCryptoTicker() + { + $tickData = [ + 'day' => [ + 'c' => 'dummyDayClose', + 'h' => 'dummyDayHigh', + 'l' => 'dummyDayLow', + 'o' => 'dummyDayOpen', + 'v' => 'dummyDayVolume', + ], + 'lastTrade' => [ + 'p' => 'dummyPrice', + 's' => 'dummySize', + 'x' => 'dummyExchange', + 'c' => 'dummyConditions', + 't' => 'dummyTimestamp', + ], + 'min' => [ + 'c' => 'dummyMinClose', + 'h' => 'dummyMinHigh', + 'l' => 'dummyMinLow', + 'o' => 'dummyMinOpen', + 'v' => 'dummyMinVolume', + ], + 'prevDay' => [ + 'c' => 'dummyPrevDayClose', + 'h' => 'dummyPrevDayHigh', + 'l' => 'dummyPrevDayLow', + 'o' => 'dummyPrevDayOpen', + 'v' => 'dummyPrevDayVolume', + ], + ]; + + $expectedReturn = [ + 'day' => [ + 'c' => 'dummyDayClose', + 'h' => 'dummyDayHigh', + 'l' => 'dummyDayLow', + 'o' => 'dummyDayOpen', + 'v' => 'dummyDayVolume', + 'close' => 'dummyDayClose', + 'high' => 'dummyDayHigh', + 'low' => 'dummyDayLow', + 'open' => 'dummyDayOpen', + 'volume' => 'dummyDayVolume', + ], + 'lastTrade' => [ + 'p' => 'dummyPrice', + 's' => 'dummySize', + 'x' => 'dummyExchange', + 'c' => 'dummyConditions', + 't' => 'dummyTimestamp', + 'price' => 'dummyPrice', + 'size' => 'dummySize', + 'exchange' => 'dummyExchange', + 'conditions' => 'dummyConditions', + 'timestamp' => 'dummyTimestamp', + ], + 'min' => [ + 'c' => 'dummyMinClose', + 'h' => 'dummyMinHigh', + 'l' => 'dummyMinLow', + 'o' => 'dummyMinOpen', + 'v' => 'dummyMinVolume', + 'close' => 'dummyMinClose', + 'high' => 'dummyMinHigh', + 'low' => 'dummyMinLow', + 'open' => 'dummyMinOpen', + 'volume' => 'dummyMinVolume', + ], + 'prevDay' => [ + 'c' => 'dummyPrevDayClose', + 'h' => 'dummyPrevDayHigh', + 'l' => 'dummyPrevDayLow', + 'o' => 'dummyPrevDayOpen', + 'v' => 'dummyPrevDayVolume', + 'close' => 'dummyPrevDayClose', + 'high' => 'dummyPrevDayHigh', + 'low' => 'dummyPrevDayLow', + 'open' => 'dummyPrevDayOpen', + 'volume' => 'dummyPrevDayVolume', + ], + ]; + + $actualReturn = Mappers::snapshotCryptoTicker($tickData); + + $this->assertEquals($expectedReturn, $actualReturn); + } +} diff --git a/tests/Rest/Crypto/AggregatesTest.php b/tests/Rest/Crypto/AggregatesTest.php new file mode 100644 index 0000000..ca9e52f --- /dev/null +++ b/tests/Rest/Crypto/AggregatesTest.php @@ -0,0 +1,28 @@ +httpClient = $this->getHttpMock( + $requestsContainer, [ + 'results' => [], + ] + ); + + $previousClose->get('AAPL', 1, '2018-2-2', '2019-2-2'); + + $this->assertPath($requestsContainer, '/v2/aggs/ticker/AAPL/range/1/days/2018-2-2/2019-2-2'); + } +} diff --git a/tests/Rest/Crypto/CryptoExchangesTest.php b/tests/Rest/Crypto/CryptoExchangesTest.php new file mode 100644 index 0000000..a31b8e3 --- /dev/null +++ b/tests/Rest/Crypto/CryptoExchangesTest.php @@ -0,0 +1,23 @@ +httpClient = $this->getHttpMock($requestsContainer); + + $cryptoExchanges->get(); + + $this->assertPath($requestsContainer, '/v1/meta/crypto-exchanges'); + } +} diff --git a/tests/Rest/Crypto/CryptoTest.php b/tests/Rest/Crypto/CryptoTest.php new file mode 100644 index 0000000..2673b12 --- /dev/null +++ b/tests/Rest/Crypto/CryptoTest.php @@ -0,0 +1,91 @@ +crypto = new Crypto('API_KEY'); + } + + public function testAggregates() + { + $this->assertInstanceOf(RestResource::class, $this->crypto->aggregates); + $this->assertInstanceOf(RestResource::class, $this->crypto->aggregates()); + } + + public function testGroupedDaily() + { + $this->assertInstanceOf(RestResource::class, $this->crypto->groupedDaily); + $this->assertInstanceOf(RestResource::class, $this->crypto->groupedDaily()); + } + + public function testPreviousClose() + { + $this->assertInstanceOf(RestResource::class, $this->crypto->previousClose); + $this->assertInstanceOf(RestResource::class, $this->crypto->previousClose()); + } + + public function testCryptoExchanges() + { + $this->assertInstanceOf(RestResource::class, $this->crypto->cryptoExchanges); + $this->assertInstanceOf(RestResource::class, $this->crypto->cryptoExchanges()); + } + + public function testLastTradeForCryptoPair() + { + $this->assertInstanceOf(RestResource::class, $this->crypto->lastTradeForCryptoPair); + $this->assertInstanceOf(RestResource::class, $this->crypto->lastTradeForCryptoPair()); + } + + public function testDailyOpenClose() + { + $this->assertInstanceOf(RestResource::class, $this->crypto->dailyOpenClose); + $this->assertInstanceOf(RestResource::class, $this->crypto->dailyOpenClose()); + } + + public function testHistoricCryptoTrade() + { + $this->assertInstanceOf(RestResource::class, $this->crypto->historicCryptoTrade); + $this->assertInstanceOf(RestResource::class, $this->crypto->historicCryptoTrade()); + } + + public function testSnapshotAllTickers() + { + $this->assertInstanceOf(RestResource::class, $this->crypto->snapshotAllTickers); + $this->assertInstanceOf(RestResource::class, $this->crypto->snapshotAllTickers()); + } + + public function testSnapshotSingleTicker() + { + $this->assertInstanceOf(RestResource::class, $this->crypto->snapshotSingleTicker); + $this->assertInstanceOf(RestResource::class, $this->crypto->snapshotSingleTicker()); + } + + public function testSnapshotGainersLosers() + { + $this->assertInstanceOf(RestResource::class, $this->crypto->snapshotGainersLosers); + $this->assertInstanceOf(RestResource::class, $this->crypto->snapshotGainersLosers()); + } + + public function testSnapshotSingleTickerFullBook() + { + $this->assertInstanceOf(RestResource::class, $this->crypto->snapshotSingleTickerFullBook); + $this->assertInstanceOf(RestResource::class, $this->crypto->snapshotSingleTickerFullBook()); + } +} diff --git a/tests/Rest/Crypto/DailyOpenCloseTest.php b/tests/Rest/Crypto/DailyOpenCloseTest.php new file mode 100644 index 0000000..70dc85d --- /dev/null +++ b/tests/Rest/Crypto/DailyOpenCloseTest.php @@ -0,0 +1,23 @@ +httpClient = $this->getHttpMock($requestsContainer); + + $dailyOpenClose->get('BTC', 'ETH', '2018-2-2'); + + $this->assertPath($requestsContainer, '/v1/open-close/crypto/BTC/ETH/2018-2-2'); + } +} diff --git a/tests/Rest/Crypto/GroupedDailyTest.php b/tests/Rest/Crypto/GroupedDailyTest.php new file mode 100644 index 0000000..c978b3d --- /dev/null +++ b/tests/Rest/Crypto/GroupedDailyTest.php @@ -0,0 +1,27 @@ +httpClient = $this->getHttpMock( + $requestsContainer, [ + 'results' => [], + ] + ); + + $groupedDaily->get('2019-2-2'); + + $this->assertPath($requestsContainer, '/v2/aggs/grouped/locale/US/market/CRYPTO/2019-2-2'); + } +} diff --git a/tests/Rest/Crypto/HistoricCryptoTradeTest.php b/tests/Rest/Crypto/HistoricCryptoTradeTest.php new file mode 100644 index 0000000..ac25097 --- /dev/null +++ b/tests/Rest/Crypto/HistoricCryptoTradeTest.php @@ -0,0 +1,27 @@ +httpClient = $this->getHttpMock( + $requestsContainer, [ + 'ticks' => [], + ] + ); + + $historicCryptoTrade->get('BTC', 'ETH', '2018-2-2'); + + $this->assertPath($requestsContainer, '/v1/historic/crypto/BTC/ETH/2018-2-2'); + } +} diff --git a/tests/Rest/Crypto/LastTradeForCryptoPairTest.php b/tests/Rest/Crypto/LastTradeForCryptoPairTest.php new file mode 100644 index 0000000..8da34a0 --- /dev/null +++ b/tests/Rest/Crypto/LastTradeForCryptoPairTest.php @@ -0,0 +1,23 @@ +httpClient = $this->getHttpMock($requestsContainer); + + $lastTradeForCryptoPair->get('BTC', 'ETH'); + + $this->assertPath($requestsContainer, '/v1/last/crypto/BTC/ETH'); + } +} diff --git a/tests/Rest/Crypto/PreviousCloseTest.php b/tests/Rest/Crypto/PreviousCloseTest.php new file mode 100644 index 0000000..b85b0d9 --- /dev/null +++ b/tests/Rest/Crypto/PreviousCloseTest.php @@ -0,0 +1,27 @@ +httpClient = $this->getHttpMock( + $requestsContainer, [ + 'results' => [], + ] + ); + + $previousClose->get('AAPL'); + + $this->assertPath($requestsContainer, '/v2/aggs/ticker/AAPL/prev'); + } +} diff --git a/tests/Rest/Crypto/SnapshotAllTickersTest.php b/tests/Rest/Crypto/SnapshotAllTickersTest.php new file mode 100644 index 0000000..61076d0 --- /dev/null +++ b/tests/Rest/Crypto/SnapshotAllTickersTest.php @@ -0,0 +1,27 @@ +httpClient = $this->getHttpMock( + $requestsContainer, [ + 'tickers' => [], + ] + ); + + $snapshotAllTickers->get(); + + $this->assertPath($requestsContainer, '/v2/snapshot/locale/global/markets/crypto/tickers'); + } +} diff --git a/tests/Rest/Crypto/SnapshotGainersLosersTest.php b/tests/Rest/Crypto/SnapshotGainersLosersTest.php new file mode 100644 index 0000000..3f692b3 --- /dev/null +++ b/tests/Rest/Crypto/SnapshotGainersLosersTest.php @@ -0,0 +1,28 @@ +httpClient = $this->getHttpMock( + $requestsContainer, [ + 'tickers' => [], + ] + ); + + $snapshotGainersLosers->get(); + + $this->assertPath($requestsContainer, '/v2/snapshot/locale/global/markets/crypto/gainers'); + } +} diff --git a/tests/Rest/Crypto/SnapshotSingleTickerFullBookTest.php b/tests/Rest/Crypto/SnapshotSingleTickerFullBookTest.php new file mode 100644 index 0000000..4f99db2 --- /dev/null +++ b/tests/Rest/Crypto/SnapshotSingleTickerFullBookTest.php @@ -0,0 +1,31 @@ +httpClient = $this->getHttpMock( + $requestsContainer, [ + 'data' => [], + ] + ); + + $snapshotSingleTickerFullBook->get('BTC-ETH'); + + $this->assertPath($requestsContainer, + '/v2/snapshot/locale/global/markets/crypto/tickers/BTC-ETH/book'); + } +} diff --git a/tests/Rest/Crypto/SnapshotSingleTickerTest.php b/tests/Rest/Crypto/SnapshotSingleTickerTest.php new file mode 100644 index 0000000..c572679 --- /dev/null +++ b/tests/Rest/Crypto/SnapshotSingleTickerTest.php @@ -0,0 +1,57 @@ +httpClient = $this->getHttpMock( + $requestsContainer, [ + 'ticker' => [ + 'day' => [ + 'c' => 'c', + 'h' => 'h', + 'l' => 'l', + 'o' => 'o', + 'v' => 'v', + ], + 'lastTrade' => [ + 'p' => 'p', + 's' => 's', + 'x' => 'x', + 'c' => 'c', + 't' => 't', + ], + 'min' => [ + 'c' => 'c', + 'h' => 'h', + 'l' => 'l', + 'o' => 'o', + 'v' => 'v', + ], + 'prevDay' => [ + 'c' => 'c', + 'h' => 'h', + 'l' => 'l', + 'o' => 'o', + 'v' => 'v', + ], + ], + ] + ); + + $singleTicker->get('BTC-ETH'); + + $this->assertPath($requestsContainer, '/v2/snapshot/locale/global/markets/crypto/tickers/BTC-ETH'); + } +} diff --git a/tests/Rest/Forex/AggregatesTest.php b/tests/Rest/Forex/AggregatesTest.php new file mode 100644 index 0000000..16a4b15 --- /dev/null +++ b/tests/Rest/Forex/AggregatesTest.php @@ -0,0 +1,27 @@ +httpClient = $this->getHttpMock( + $requestsContainer, [ + 'results' => [], + ] + ); + + $previousClose->get('AAPL', 1, '2018-2-2', '2019-2-2'); + + $this->assertPath($requestsContainer, '/v2/aggs/ticker/AAPL/range/1/days/2018-2-2/2019-2-2'); + } +} diff --git a/tests/Rest/Forex/ForexTest.php b/tests/Rest/Forex/ForexTest.php new file mode 100644 index 0000000..4516288 --- /dev/null +++ b/tests/Rest/Forex/ForexTest.php @@ -0,0 +1,74 @@ +forex = new Forex('API_KEY'); + } + + public function testAggregates() + { + $this->assertInstanceOf(RestResource::class, $this->forex->aggregates); + $this->assertInstanceOf(RestResource::class, $this->forex->aggregates()); + } + + public function testGroupedDaily() + { + $this->assertInstanceOf(RestResource::class, $this->forex->groupedDaily); + $this->assertInstanceOf(RestResource::class, $this->forex->groupedDaily()); + } + + public function testPreviousClose() + { + $this->assertInstanceOf(RestResource::class, $this->forex->previousClose); + $this->assertInstanceOf(RestResource::class, $this->forex->previousClose()); + } + + public function testHistoricForexTick() + { + $this->assertInstanceOf(RestResource::class, $this->forex->historicForexTick); + $this->assertInstanceOf(RestResource::class, $this->forex->historicForexTick()); + } + + public function testRealTimeCurrencyConversion() + { + $this->assertInstanceOf(RestResource::class, $this->forex->realTimeCurrencyConversion); + $this->assertInstanceOf(RestResource::class, $this->forex->realTimeCurrencyConversion()); + } + + public function testLastQuoteForCurrencyPair() + { + $this->assertInstanceOf(RestResource::class, $this->forex->lastQuoteForCurrencyPair); + $this->assertInstanceOf(RestResource::class, $this->forex->lastQuoteForCurrencyPair()); + } + + public function testSnapshotGainersLosers() + { + $this->assertInstanceOf(RestResource::class, $this->forex->snapshotGainersLosers); + $this->assertInstanceOf(RestResource::class, $this->forex->snapshotGainersLosers()); + } + + public function testSnapshotAllTickers() + { + $this->assertInstanceOf(RestResource::class, $this->forex->snapshotAllTickers); + $this->assertInstanceOf(RestResource::class, $this->forex->snapshotAllTickers()); + } +} diff --git a/tests/Rest/Forex/GroupedDailyTest.php b/tests/Rest/Forex/GroupedDailyTest.php new file mode 100644 index 0000000..28fdff3 --- /dev/null +++ b/tests/Rest/Forex/GroupedDailyTest.php @@ -0,0 +1,27 @@ +httpClient = $this->getHttpMock( + $requestsContainer, [ + 'results' => [], + ] + ); + + $groupedDaily->get('2019-2-2'); + + $this->assertPath($requestsContainer, '/v2/aggs/grouped/locale/US/market/FX/2019-2-2'); + } +} diff --git a/tests/Rest/Forex/HistoricForexTickTest.php b/tests/Rest/Forex/HistoricForexTickTest.php new file mode 100644 index 0000000..d1df97c --- /dev/null +++ b/tests/Rest/Forex/HistoricForexTickTest.php @@ -0,0 +1,23 @@ +httpClient = $this->getHttpMock($requestsContainer); + + $historicForexTick->get('USD', 'AUD', '2018-2-2'); + + $this->assertPath($requestsContainer, '/v1/historic/forex/USD/AUD/2018-2-2'); + } +} diff --git a/tests/Rest/Forex/LastQuoteForCurrencyPairTest.php b/tests/Rest/Forex/LastQuoteForCurrencyPairTest.php new file mode 100644 index 0000000..92e042c --- /dev/null +++ b/tests/Rest/Forex/LastQuoteForCurrencyPairTest.php @@ -0,0 +1,23 @@ +httpClient = $this->getHttpMock($requestsContainer); + + $lastQuoteForCurrencyPair->get('USD', 'AUD'); + + $this->assertPath($requestsContainer, '/v1/last_quote/currencies/USD/AUD'); + } +} diff --git a/tests/Rest/Forex/PreviousCloseTest.php b/tests/Rest/Forex/PreviousCloseTest.php new file mode 100644 index 0000000..204dd85 --- /dev/null +++ b/tests/Rest/Forex/PreviousCloseTest.php @@ -0,0 +1,27 @@ +httpClient = $this->getHttpMock( + $requestsContainer, [ + 'results' => [], + ] + ); + + $previousClose->get('AAPL'); + + $this->assertPath($requestsContainer, '/v2/aggs/ticker/AAPL/prev'); + } +} diff --git a/tests/Rest/Forex/RealTimeCurrencyConversionTest.php b/tests/Rest/Forex/RealTimeCurrencyConversionTest.php new file mode 100644 index 0000000..ce34875 --- /dev/null +++ b/tests/Rest/Forex/RealTimeCurrencyConversionTest.php @@ -0,0 +1,23 @@ +httpClient = $this->getHttpMock($requestsContainer); + + $realTimeCurrencyConversion->get('USD', 'AUD'); + + $this->assertPath($requestsContainer, '/v1/conversion/USD/AUD'); + } +} diff --git a/tests/Rest/Forex/SnapshotAllTickersTest.php b/tests/Rest/Forex/SnapshotAllTickersTest.php new file mode 100644 index 0000000..1730d74 --- /dev/null +++ b/tests/Rest/Forex/SnapshotAllTickersTest.php @@ -0,0 +1,27 @@ +httpClient = $this->getHttpMock( + $requestsContainer, [ + 'tickers' => [], + ] + ); + + $snapshotAllTickers->get(); + + $this->assertPath($requestsContainer, '/v2/snapshot/locale/global/markets/forex/tickers'); + } +} diff --git a/tests/Rest/Forex/SnapshotGainersLosersTest.php b/tests/Rest/Forex/SnapshotGainersLosersTest.php new file mode 100644 index 0000000..13b0e70 --- /dev/null +++ b/tests/Rest/Forex/SnapshotGainersLosersTest.php @@ -0,0 +1,27 @@ +httpClient = $this->getHttpMock( + $requestsContainer, [ + 'tickers' => [], + ] + ); + + $snapshotGainersLosers->get(); + + $this->assertPath($requestsContainer, '/v2/snapshot/locale/global/markets/forex/gainers'); + } +} diff --git a/tests/Rest/Reference/LocalesTest.php b/tests/Rest/Reference/LocalesTest.php new file mode 100644 index 0000000..f738ed4 --- /dev/null +++ b/tests/Rest/Reference/LocalesTest.php @@ -0,0 +1,23 @@ +httpClient = $this->getHttpMock($requestsContainer); + + $locales->get(); + + $this->assertPath($requestsContainer, '/v2/reference/locales'); + } +} diff --git a/tests/Rest/Reference/MarketHolidaysTest.php b/tests/Rest/Reference/MarketHolidaysTest.php new file mode 100644 index 0000000..d694045 --- /dev/null +++ b/tests/Rest/Reference/MarketHolidaysTest.php @@ -0,0 +1,23 @@ +httpClient = $this->getHttpMock($requestsContainer); + + $marketHolidays->get(); + + $this->assertPath($requestsContainer, '/v1/marketstatus/upcoming'); + } +} diff --git a/tests/Rest/Reference/MarketStatusTest.php b/tests/Rest/Reference/MarketStatusTest.php new file mode 100644 index 0000000..bcf0902 --- /dev/null +++ b/tests/Rest/Reference/MarketStatusTest.php @@ -0,0 +1,23 @@ +httpClient = $this->getHttpMock($requestsContainer); + + $marketStatus->get(); + + $this->assertPath($requestsContainer, '/v1/marketstatus/now'); + } +} diff --git a/tests/Rest/Reference/MarketsTest.php b/tests/Rest/Reference/MarketsTest.php new file mode 100644 index 0000000..222b454 --- /dev/null +++ b/tests/Rest/Reference/MarketsTest.php @@ -0,0 +1,23 @@ +httpClient = $this->getHttpMock($requestsContainer); + + $markets->get(); + + $this->assertPath($requestsContainer, '/v2/reference/markets'); + } +} diff --git a/tests/Rest/Reference/ReferenceTest.php b/tests/Rest/Reference/ReferenceTest.php new file mode 100644 index 0000000..5a5c98a --- /dev/null +++ b/tests/Rest/Reference/ReferenceTest.php @@ -0,0 +1,88 @@ +reference = new Reference('API_KEY'); + } + + public function testTickers() + { + $this->assertInstanceOf(RestResource::class, $this->reference->Tickers()); + $this->assertInstanceOf(RestResource::class, $this->reference->tickers); + } + + public function testTickerTypes() + { + $this->assertInstanceOf(RestResource::class, $this->reference->TickerTypes()); + $this->assertInstanceOf(RestResource::class, $this->reference->tickerTypes); + } + + public function testTickerDetails() + { + $this->assertInstanceOf(RestResource::class, $this->reference->TickerDetails()); + $this->assertInstanceOf(RestResource::class, $this->reference->tickerDetails); + } + + public function testTickerNews() + { + $this->assertInstanceOf(RestResource::class, $this->reference->TickerNews()); + $this->assertInstanceOf(RestResource::class, $this->reference->tickerNews); + } + + public function testMarkets() + { + $this->assertInstanceOf(RestResource::class, $this->reference->Markets()); + $this->assertInstanceOf(RestResource::class, $this->reference->markets); + } + + public function testLocales() + { + $this->assertInstanceOf(RestResource::class, $this->reference->Locales()); + $this->assertInstanceOf(RestResource::class, $this->reference->locales); + } + + public function testStockSplits() + { + $this->assertInstanceOf(RestResource::class, $this->reference->StockSplits()); + $this->assertInstanceOf(RestResource::class, $this->reference->stockSplits); + } + + public function testStockDividends() + { + $this->assertInstanceOf(RestResource::class, $this->reference->StockDividends()); + $this->assertInstanceOf(RestResource::class, $this->reference->stockDividends); + } + + public function testStockFinancials() + { + $this->assertInstanceOf(RestResource::class, $this->reference->StockFinancials()); + $this->assertInstanceOf(RestResource::class, $this->reference->stockFinancials); + } + + public function testMarketStatus() + { + $this->assertInstanceOf(RestResource::class, $this->reference->MarketStatus()); + $this->assertInstanceOf(RestResource::class, $this->reference->marketStatus); + } + + public function testMarketHolidays() + { + $this->assertInstanceOf(RestResource::class, $this->reference->MarketHolidays()); + $this->assertInstanceOf(RestResource::class, $this->reference->marketHolidays); + } +} diff --git a/tests/Rest/Reference/StockDividendsTest.php b/tests/Rest/Reference/StockDividendsTest.php new file mode 100644 index 0000000..2215fd6 --- /dev/null +++ b/tests/Rest/Reference/StockDividendsTest.php @@ -0,0 +1,23 @@ +httpClient = $this->getHttpMock($requestsContainer); + + $stockDividends->get('AAPL'); + + $this->assertPath($requestsContainer, '/v2/reference/dividends/AAPL'); + } +} diff --git a/tests/Rest/Reference/StockFinancialsTest.php b/tests/Rest/Reference/StockFinancialsTest.php new file mode 100644 index 0000000..be47972 --- /dev/null +++ b/tests/Rest/Reference/StockFinancialsTest.php @@ -0,0 +1,23 @@ +httpClient = $this->getHttpMock($requestsContainer); + + $stockFinancials->get('AAPL'); + + $this->assertPath($requestsContainer, '/v2/reference/financials/AAPL'); + } +} diff --git a/tests/Rest/Reference/StockSplitsTest.php b/tests/Rest/Reference/StockSplitsTest.php new file mode 100644 index 0000000..c7543bf --- /dev/null +++ b/tests/Rest/Reference/StockSplitsTest.php @@ -0,0 +1,23 @@ +httpClient = $this->getHttpMock($requestsContainer); + + $stockSplits->get('AAPL'); + + $this->assertPath($requestsContainer, '/v2/reference/splits/AAPL'); + } +} diff --git a/tests/Rest/Reference/TickerDetailsTest.php b/tests/Rest/Reference/TickerDetailsTest.php new file mode 100644 index 0000000..f53fa9e --- /dev/null +++ b/tests/Rest/Reference/TickerDetailsTest.php @@ -0,0 +1,30 @@ + 'lei_remapped', + 'sic' => 'sic_remapped' + ]; + $tickerDetails = new TickerDetails('fake-api-key'); + $tickerDetails->httpClient = $this->getHttpMock($requestsContainer, $response); + + $apiResponse = $tickerDetails->get('AAPL'); + + $this->assertPath($requestsContainer, '/v1/meta/symbols/AAPL/company'); + $this->assertEquals('lei_remapped', $apiResponse['legalEntityIdentifier']); + $this->assertEquals('sic_remapped', $apiResponse['standardIndustryClassification']); + } +} diff --git a/tests/Rest/Reference/TickerNewsTest.php b/tests/Rest/Reference/TickerNewsTest.php new file mode 100644 index 0000000..412ba41 --- /dev/null +++ b/tests/Rest/Reference/TickerNewsTest.php @@ -0,0 +1,22 @@ +httpClient = $this->getHttpMock($requestsContainer); + + $tickerNews->get('AAPL'); + + $this->assertPath($requestsContainer, '/v1/meta/symbols/AAPL/news'); + } +} diff --git a/tests/Rest/Reference/TickerTypesTest.php b/tests/Rest/Reference/TickerTypesTest.php new file mode 100644 index 0000000..04abfc2 --- /dev/null +++ b/tests/Rest/Reference/TickerTypesTest.php @@ -0,0 +1,23 @@ +httpClient = $this->getHttpMock($requestsContainer); + + $tickerTypes->get(); + + $this->assertPath($requestsContainer, '/v2/reference/types'); + } +} diff --git a/tests/Rest/Reference/TickersTest.php b/tests/Rest/Reference/TickersTest.php new file mode 100644 index 0000000..ccc64d8 --- /dev/null +++ b/tests/Rest/Reference/TickersTest.php @@ -0,0 +1,23 @@ +httpClient = $this->getHttpMock($requestsContainer); + + $tickers->get(); + + $this->assertPath($requestsContainer, '/v2/reference/tickers'); + } +} diff --git a/tests/Rest/Stocks/AggregatesTest.php b/tests/Rest/Stocks/AggregatesTest.php new file mode 100644 index 0000000..5d6dc64 --- /dev/null +++ b/tests/Rest/Stocks/AggregatesTest.php @@ -0,0 +1,27 @@ +httpClient = $this->getHttpMock( + $requestsContainer, [ + 'results' => [], + ] + ); + + $previousClose->get('AAPL', 1, '2018-2-2', '2019-2-2'); + + $this->assertPath($requestsContainer, '/v2/aggs/ticker/AAPL/range/1/days/2018-2-2/2019-2-2'); + } +} diff --git a/tests/Rest/Stocks/ConditionMappingsTest.php b/tests/Rest/Stocks/ConditionMappingsTest.php new file mode 100644 index 0000000..eb3f038 --- /dev/null +++ b/tests/Rest/Stocks/ConditionMappingsTest.php @@ -0,0 +1,24 @@ +httpClient = $this->getHttpMock($requestsContainer); + + $conditionMappings->get(); + + $this->assertPath($requestsContainer, '/v1/meta/conditions/trades'); + } + +} diff --git a/tests/Rest/Stocks/DailyOpenCloseTest.php b/tests/Rest/Stocks/DailyOpenCloseTest.php new file mode 100644 index 0000000..f7cfe65 --- /dev/null +++ b/tests/Rest/Stocks/DailyOpenCloseTest.php @@ -0,0 +1,23 @@ +httpClient = $this->getHttpMock($requestsContainer); + + $dailyOpenClose->get('AAPL', '2019-2-2'); + + $this->assertPath($requestsContainer, '/v1/open-close/AAPL/2019-2-2'); + } +} diff --git a/tests/Rest/Stocks/ExchangesTest.php b/tests/Rest/Stocks/ExchangesTest.php new file mode 100644 index 0000000..ae775f8 --- /dev/null +++ b/tests/Rest/Stocks/ExchangesTest.php @@ -0,0 +1,23 @@ +httpClient = $this->getHttpMock($requestsContainer); + + $exchanges->get(); + + $this->assertPath($requestsContainer, '/v1/meta/exchanges'); + } +} diff --git a/tests/Rest/Stocks/GroupedDailyTest.php b/tests/Rest/Stocks/GroupedDailyTest.php new file mode 100644 index 0000000..4cda1b3 --- /dev/null +++ b/tests/Rest/Stocks/GroupedDailyTest.php @@ -0,0 +1,27 @@ +httpClient = $this->getHttpMock( + $requestsContainer, [ + 'results' => [], + ] + ); + + $groupedDaily->get('2019-2-2'); + + $this->assertPath($requestsContainer, '/v2/aggs/grouped/locale/US/market/STOCKS/2019-2-2'); + } +} diff --git a/tests/Rest/Stocks/HistoricQuotesTest.php b/tests/Rest/Stocks/HistoricQuotesTest.php new file mode 100644 index 0000000..df2dd48 --- /dev/null +++ b/tests/Rest/Stocks/HistoricQuotesTest.php @@ -0,0 +1,27 @@ +httpClient = $this->getHttpMock( + $requestsContainer, [ + 'ticks' => [], + ] + ); + + $historicQuotes->get('AAPL', '2019-2-2'); + + $this->assertPath($requestsContainer, '/v1/historic/quotes/AAPL/2019-2-2'); + } +} diff --git a/tests/Rest/Stocks/HistoricQuotesV2Test.php b/tests/Rest/Stocks/HistoricQuotesV2Test.php new file mode 100644 index 0000000..f3f879d --- /dev/null +++ b/tests/Rest/Stocks/HistoricQuotesV2Test.php @@ -0,0 +1,27 @@ +httpClient = $this->getHttpMock( + $requestsContainer, [ + 'results' => [], + ] + ); + + $historicQuotesV2->get('AAPL', '2019-2-2'); + + $this->assertPath($requestsContainer, '/v2/ticks/stocks/nbbo/AAPL/2019-2-2'); + } +} diff --git a/tests/Rest/Stocks/HistoricTradesTest.php b/tests/Rest/Stocks/HistoricTradesTest.php new file mode 100644 index 0000000..6eb27fb --- /dev/null +++ b/tests/Rest/Stocks/HistoricTradesTest.php @@ -0,0 +1,29 @@ +httpClient = $this->getHttpMock( + $requestsContainer, [ + 'ticks' => [], + ] + ); + + $historicTrades->get('AAPL', '2019-2-2'); + + $this->assertPath($requestsContainer, '/v1/historic/trades/AAPL/2019-2-2'); + } +} diff --git a/tests/Rest/Stocks/HistoricTradesV2Test.php b/tests/Rest/Stocks/HistoricTradesV2Test.php new file mode 100644 index 0000000..ed7563d --- /dev/null +++ b/tests/Rest/Stocks/HistoricTradesV2Test.php @@ -0,0 +1,27 @@ +httpClient = $this->getHttpMock( + $requestsContainer, [ + 'ticks' => [], + ] + ); + + $historicTradesV2->get('AAPL', '2019-2-2'); + + $this->assertPath($requestsContainer, '/v2/ticks/stocks/trades/AAPL/2019-2-2'); + } +} diff --git a/tests/Rest/Stocks/LastQuoteForSymbolTest.php b/tests/Rest/Stocks/LastQuoteForSymbolTest.php new file mode 100644 index 0000000..fb89759 --- /dev/null +++ b/tests/Rest/Stocks/LastQuoteForSymbolTest.php @@ -0,0 +1,23 @@ +httpClient = $this->getHttpMock($requestsContainer); + + $lastTradeForSymbol->get('AAPL'); + + $this->assertPath($requestsContainer, '/v1/last_quote/stocks/AAPL'); + } +} diff --git a/tests/Rest/Stocks/LastTradeForSymbolTest.php b/tests/Rest/Stocks/LastTradeForSymbolTest.php new file mode 100644 index 0000000..4fdddb5 --- /dev/null +++ b/tests/Rest/Stocks/LastTradeForSymbolTest.php @@ -0,0 +1,23 @@ +httpClient = $this->getHttpMock($requestsContainer); + + $lastTradeForSymbol->get('AAPL'); + + $this->assertPath($requestsContainer, '/v1/last/stocks/AAPL'); + } +} diff --git a/tests/Rest/Stocks/PreviousCloseTest.php b/tests/Rest/Stocks/PreviousCloseTest.php new file mode 100644 index 0000000..98fce96 --- /dev/null +++ b/tests/Rest/Stocks/PreviousCloseTest.php @@ -0,0 +1,27 @@ +httpClient = $this->getHttpMock( + $requestsContainer, [ + 'results' => [], + ] + ); + + $previousClose->get('AAPL'); + + $this->assertPath($requestsContainer, '/v2/aggs/ticker/AAPL/prev'); + } +} diff --git a/tests/Rest/Stocks/SnapshotAllTickersTest.php b/tests/Rest/Stocks/SnapshotAllTickersTest.php new file mode 100644 index 0000000..eccd5c9 --- /dev/null +++ b/tests/Rest/Stocks/SnapshotAllTickersTest.php @@ -0,0 +1,27 @@ +httpClient = $this->getHttpMock( + $requestsContainer, [ + 'tickers' => [], + ] + ); + + $snapshotAllTickers->get(); + + $this->assertPath($requestsContainer, '/v2/snapshot/locale/us/markets/stocks/tickers'); + } +} diff --git a/tests/Rest/Stocks/SnapshotGainersLosersTest.php b/tests/Rest/Stocks/SnapshotGainersLosersTest.php new file mode 100644 index 0000000..f3b0d6e --- /dev/null +++ b/tests/Rest/Stocks/SnapshotGainersLosersTest.php @@ -0,0 +1,26 @@ +httpClient = $this->getHttpMock( + $requestsContainer, [ + 'tickers' => [], + ] + ); + + $snapshotGainersLosers->get(); + $this->assertPath($requestsContainer, '/v2/snapshot/locale/us/markets/stocks/gainers'); + } +} diff --git a/tests/Rest/Stocks/SnapshotSingleTickerTest.php b/tests/Rest/Stocks/SnapshotSingleTickerTest.php new file mode 100644 index 0000000..74bab59 --- /dev/null +++ b/tests/Rest/Stocks/SnapshotSingleTickerTest.php @@ -0,0 +1,67 @@ +httpClient = $this->getHttpMock( + $requestsContainer, [ + 'ticker' => [ + 'day' => [ + 'c' => 'c', + 'h' => 'h', + 'l' => 'l', + 'o' => 'o', + 'v' => 'v', + ], + 'lastTrade' => [ + 'c1' => 'c1', + 'c2' => 'c2', + 'c3' => 'c3', + 'c4' => 'c4', + 'e' => 'e', + 'p' => 'p', + 's' => 's', + 't' => 't', + ], + 'lastQuote' => [ + 'p' => 'p', + 's' => 's', + 'S' => 'S', + 'P' => 'P', + 't' => 't', + ], + 'min' => [ + 'c' => 'c', + 'h' => 'h', + 'l' => 'l', + 'o' => 'o', + 'v' => 'v', + ], + 'prevDay' => [ + 'c' => 'c', + 'h' => 'h', + 'l' => 'l', + 'o' => 'o', + 'v' => 'v', + ], + ], + ] + ); + + $singleTicker->get('AAPL'); + + $this->assertPath($requestsContainer, '/v2/snapshot/locale/us/markets/stocks/tickers/AAPL'); + } +} diff --git a/tests/Rest/Stocks/StocksTest.php b/tests/Rest/Stocks/StocksTest.php new file mode 100644 index 0000000..898e23c --- /dev/null +++ b/tests/Rest/Stocks/StocksTest.php @@ -0,0 +1,116 @@ +stocks = new Stocks('API_KEY'); + } + + public function testExchanges() + { + $this->assertInstanceOf(RestResource::class, $this->stocks->exchanges); + $this->assertInstanceOf(RestResource::class, $this->stocks->exchanges()); + } + + public function testHistoricTrades() + { + $this->assertInstanceOf(RestResource::class, $this->stocks->historicTrades); + $this->assertInstanceOf(RestResource::class, $this->stocks->historicTrades()); + } + + public function testHistoricTradesV2() + { + $this->assertInstanceOf(RestResource::class, $this->stocks->historicTradesV2); + $this->assertInstanceOf(RestResource::class, $this->stocks->historicTradesV2()); + } + + public function testHistoricQuotes() + { + $this->assertInstanceOf(RestResource::class, $this->stocks->historicQuotes); + $this->assertInstanceOf(RestResource::class, $this->stocks->historicQuotes()); + } + + public function testHistoricQuotesV2() + { + $this->assertInstanceOf(RestResource::class, $this->stocks->historicQuotesV2); + $this->assertInstanceOf(RestResource::class, $this->stocks->historicQuotesV2()); + } + + public function testLastTradeForSymbol() + { + $this->assertInstanceOf(RestResource::class, $this->stocks->lastTradeForSymbol); + $this->assertInstanceOf(RestResource::class, $this->stocks->lastTradeForSymbol()); + } + + public function testLastQuoteForSymbol() + { + $this->assertInstanceOf(RestResource::class, $this->stocks->lastQuoteForSymbol); + $this->assertInstanceOf(RestResource::class, $this->stocks->lastQuoteForSymbol()); + } + + public function testDailyOpenClose() + { + $this->assertInstanceOf(RestResource::class, $this->stocks->dailyOpenClose); + $this->assertInstanceOf(RestResource::class, $this->stocks->dailyOpenClose()); + } + + public function testConditionMappings() + { + $this->assertInstanceOf(RestResource::class, $this->stocks->conditionMappings); + $this->assertInstanceOf(RestResource::class, $this->stocks->conditionMappings()); + } + + public function testSnapshotAllTickers() + { + $this->assertInstanceOf(RestResource::class, $this->stocks->snapshotAllTickers); + $this->assertInstanceOf(RestResource::class, $this->stocks->snapshotAllTickers()); + } + + public function testSnapshotSingleTicker() + { + $this->assertInstanceOf(RestResource::class, $this->stocks->snapshotSingleTicker); + $this->assertInstanceOf(RestResource::class, $this->stocks->snapshotSingleTicker()); + } + + public function testSnapshotGainersLosers() + { + $this->assertInstanceOf(RestResource::class, $this->stocks->snapshotGainersLosers); + $this->assertInstanceOf(RestResource::class, $this->stocks->snapshotGainersLosers()); + } + + public function testPreviousClose() + { + $this->assertInstanceOf(RestResource::class, $this->stocks->previousClose); + $this->assertInstanceOf(RestResource::class, $this->stocks->previousClose()); + } + + public function testAggregates() + { + $this->assertInstanceOf(RestResource::class, $this->stocks->aggregates); + $this->assertInstanceOf(RestResource::class, $this->stocks->aggregates()); + } + + public function testGroupedDaily() + { + $this->assertInstanceOf(RestResource::class, $this->stocks->groupedDaily); + $this->assertInstanceOf(RestResource::class, $this->stocks->groupedDaily()); + } +} diff --git a/tests/rest/CryptoTest.php b/tests/rest/CryptoTest.php deleted file mode 100644 index 3e9ff08..0000000 --- a/tests/rest/CryptoTest.php +++ /dev/null @@ -1,214 +0,0 @@ -assertInstanceOf(Aggregates::class, $crypto->aggregates); - $this->assertInstanceOf(GroupedDaily::class, $crypto->groupedDaily); - $this->assertInstanceOf(PreviousClose::class, $crypto->previousClose); - $this->assertInstanceOf(CryptoExchanges::class, $crypto->cryptoExchanges); - $this->assertInstanceOf(LastTradeForCryptoPair::class, $crypto->lastTradeForCryptoPair); - $this->assertInstanceOf(DailyOpenClose::class, $crypto->dailyOpenClose); - $this->assertInstanceOf(HistoricCryptoTrade::class, $crypto->historicCryptoTrade); - $this->assertInstanceOf(SnapshotAllTickers::class, $crypto->snapshotAllTickers); - $this->assertInstanceOf(SnapshotSingleTicker::class, $crypto->snapshotSingleTicker); - $this->assertInstanceOf(SnapshotGainersLosers::class, $crypto->snapshotGainersLosers); - $this->assertInstanceOf(SnapshotSingleTickerFullBook::class, $crypto->snapshotSingleTickerFullBook); - } - - public function testPreviousCloseGetCall() { - $requestsContainer = []; - - $previousClose = new PreviousClose('fake-api-key'); - $previousClose->httpClient = $this->getHttpMock($requestsContainer, [ - 'results' => [], - ]); - - $previousClose->get('AAPL'); - - $this->assertPath($requestsContainer, '/v2/aggs/ticker/AAPL/prev'); - } - - public function testAggregatesCloseGetCall() { - $requestsContainer = []; - - $previousClose = new Aggregates('fake-api-key'); - $previousClose->httpClient = $this->getHttpMock($requestsContainer, [ - 'results' => [], - ]); - - $previousClose->get('AAPL', 1, '2018-2-2', '2019-2-2'); - - $this->assertPath($requestsContainer, '/v2/aggs/ticker/AAPL/range/1/days/2018-2-2/2019-2-2'); - } - - public function testGroupedDailyGetCall() { - $requestsContainer = []; - - $groupedDaily = new GroupedDaily('fake-api-key'); - $groupedDaily->httpClient = $this->getHttpMock($requestsContainer, [ - 'results' => [], - ]); - - $groupedDaily->get('2019-2-2'); - - $this->assertPath($requestsContainer, '/v2/aggs/grouped/locale/US/market/CRYPTO/2019-2-2'); - } - - public function testCryptoExchangesGetCall() { - $requestsContainer = []; - - $cryptoExchanges = new CryptoExchanges('fake-api-key'); - $cryptoExchanges->httpClient = $this->getHttpMock($requestsContainer); - - $cryptoExchanges->get(); - - $this->assertPath($requestsContainer, '/v1/meta/crypto-exchanges'); - } - - - public function testLastTradeForCryptoPairGetCall() { - $requestsContainer = []; - - $lastTradeForCryptoPair = new LastTradeForCryptoPair('fake-api-key'); - $lastTradeForCryptoPair->httpClient = $this->getHttpMock($requestsContainer); - - $lastTradeForCryptoPair->get('BTC', 'ETH'); - - $this->assertPath($requestsContainer, '/v1/last/crypto/BTC/ETH'); - } - - public function testDailtOpenCloseGetCall() { - $requestsContainer = []; - - $dailyOpenClose = new DailyOpenClose('fake-api-key'); - $dailyOpenClose->httpClient = $this->getHttpMock($requestsContainer); - - $dailyOpenClose->get('BTC', 'ETH', '2018-2-2'); - - $this->assertPath($requestsContainer, '/v1/open-close/crypto/BTC/ETH/2018-2-2'); - } - - public function testHistoricCryptoTradeGetCall() { - $requestsContainer = []; - - $historicCryptoTrade = new HistoricCryptoTrade('fake-api-key'); - $historicCryptoTrade->httpClient = $this->getHttpMock($requestsContainer, [ - 'ticks' => [], - ]); - - $historicCryptoTrade->get('BTC', 'ETH', '2018-2-2'); - - $this->assertPath($requestsContainer, '/v1/historic/crypto/BTC/ETH/2018-2-2'); - } - - public function testSnapshotAllTickersGetCall() { - $requestsContainer = []; - - $snapshotAllTickers = new SnapshotAllTickers('fake-api-key'); - $snapshotAllTickers->httpClient = $this->getHttpMock($requestsContainer, [ - 'tickers' => [], - ]); - - $snapshotAllTickers->get(); - - $this->assertPath($requestsContainer, '/v2/snapshot/locale/global/markets/crypto/tickers'); - } - - public function testSnapshotSingleTickerGetCall() { - $requestsContainer = []; - - $singleTicker = new SnapshotSingleTicker('fake-api-key'); - - $singleTicker->httpClient = $this->getHttpMock($requestsContainer, [ - 'ticker' => [ - 'day' => [ - 'c' => 'c', - 'h' => 'h', - 'l' => 'l', - 'o' => 'o', - 'v' => 'v', - ], - 'lastTrade' => [ - 'p' => 'p', - 's' => 's', - 'x' => 'x', - 'c' => 'c', - 't' => 't', - ], - 'min' => [ - 'c' => 'c', - 'h' => 'h', - 'l' => 'l', - 'o' => 'o', - 'v' => 'v', - ], - 'prevDay' => [ - 'c' => 'c', - 'h' => 'h', - 'l' => 'l', - 'o' => 'o', - 'v' => 'v', - ], - ], - ]); - - $singleTicker->get('BTC-ETH'); - - $this->assertPath($requestsContainer, '/v2/snapshot/locale/global/markets/crypto/tickers/BTC-ETH'); - } - - public function testSnapshotGainersLosersGetCall() { - $requestsContainer = []; - - $snapshotGainersLosers = new SnapshotGainersLosers('fake-api-key'); - $snapshotGainersLosers->httpClient = $this->getHttpMock($requestsContainer, [ - 'tickers' => [], - ]); - - $snapshotGainersLosers->get(); - - $this->assertPath($requestsContainer, '/v2/snapshot/locale/global/markets/crypto/gainers'); - } - - public function testSnapshotSingleTickerFullbookGetCall() { - $requestsContainer = []; - - $snapshotSingleTickerFullBook = new SnapshotSingleTickerFullBook('fake-api-key'); - - $snapshotSingleTickerFullBook->httpClient = $this->getHttpMock($requestsContainer, [ - 'data' => [], - ]); - - $snapshotSingleTickerFullBook->get('BTC-ETH'); - - $this->assertPath($requestsContainer, '/v2/snapshot/locale/global/markets/crypto/tickers/BTC-ETH/book'); - } - - private function getHttpMock(&$requestsContainer, $response=[]) { - - $mock = new MockHandler([ - new Response(200, [], json_encode($response)), - ]); - $handler = HandlerStack::create($mock); - - $history = Middleware::history($requestsContainer); - $handler->push($history); - - return new Client(['handler' => $handler]); - } - - private function assertPath($requests, $path) { - $this->assertCount(1, $requests); - $this->assertEquals($path, $requests[0]['request']->getUri()->getPath()); - } -} \ No newline at end of file diff --git a/tests/rest/ForexTest.php b/tests/rest/ForexTest.php deleted file mode 100644 index 7e853e3..0000000 --- a/tests/rest/ForexTest.php +++ /dev/null @@ -1,140 +0,0 @@ -assertInstanceOf(Aggregates::class, $forex->aggregates); - $this->assertInstanceOf(GroupedDaily::class, $forex->groupedDaily); - $this->assertInstanceOf(PreviousClose::class, $forex->previousClose); - $this->assertInstanceOf(HistoricForexTick::class, $forex->historicForexTick); - $this->assertInstanceOf(RealTimeCurrencyConversion::class, $forex->realTimeCurrencyConversion); - $this->assertInstanceOf(LastQuoteForCurrencyPair::class, $forex->lastQuoteForCurrencyPair); - $this->assertInstanceOf(SnapshotGainersLosers::class, $forex->snapshotGainersLosers); - $this->assertInstanceOf(SnapshotAllTickers::class, $forex->snapshotAllTickers); - } - - public function testPreviousCloseGetCall() { - $requestsContainer = []; - - $previousClose = new PreviousClose('fake-api-key'); - $previousClose->httpClient = $this->getHttpMock($requestsContainer, [ - 'results' => [], - ]); - - $previousClose->get('AAPL'); - - $this->assertPath($requestsContainer, '/v2/aggs/ticker/AAPL/prev'); - } - - public function testAggregatesCloseGetCall() { - $requestsContainer = []; - - $previousClose = new Aggregates('fake-api-key'); - $previousClose->httpClient = $this->getHttpMock($requestsContainer, [ - 'results' => [], - ]); - - $previousClose->get('AAPL', 1, '2018-2-2', '2019-2-2'); - - $this->assertPath($requestsContainer, '/v2/aggs/ticker/AAPL/range/1/days/2018-2-2/2019-2-2'); - } - - public function testGroupedDailyGetCall() { - $requestsContainer = []; - - $groupedDaily = new GroupedDaily('fake-api-key'); - $groupedDaily->httpClient = $this->getHttpMock($requestsContainer, [ - 'results' => [], - ]); - - $groupedDaily->get('2019-2-2'); - - $this->assertPath($requestsContainer, '/v2/aggs/grouped/locale/US/market/FX/2019-2-2'); - } - - public function testHistoricForexTickGetCall() { - $requestsContainer = []; - - $historicForexTick = new HistoricForexTick('fake-api-key'); - $historicForexTick->httpClient = $this->getHttpMock($requestsContainer); - - $historicForexTick->get('USD', 'AUD', '2018-2-2'); - - $this->assertPath($requestsContainer, '/v1/historic/forex/USD/AUD/2018-2-2'); - } - - public function testRealTimeCurrencyConversionGetCall() { - $requestsContainer = []; - - $realTimeCurrencyConversion = new RealTimeCurrencyConversion('fake-api-key'); - $realTimeCurrencyConversion->httpClient = $this->getHttpMock($requestsContainer); - - $realTimeCurrencyConversion->get('USD', 'AUD'); - - $this->assertPath($requestsContainer, '/v1/conversion/USD/AUD'); - } - - public function testLastQuoteForCurrencyPairGetCall() { - $requestsContainer = []; - - $lastQuoteForCurrencyPair = new LastQuoteForCurrencyPair('fake-api-key'); - $lastQuoteForCurrencyPair->httpClient = $this->getHttpMock($requestsContainer); - - $lastQuoteForCurrencyPair->get('USD', 'AUD'); - - $this->assertPath($requestsContainer, '/v1/last_quote/currencies/USD/AUD'); - } - - public function testSnapshotGainersLosersGetCall() { - $requestsContainer = []; - - $snapshotGainersLosers = new SnapshotGainersLosers('fake-api-key'); - $snapshotGainersLosers->httpClient = $this->getHttpMock($requestsContainer, [ - 'tickers' => [], - ]); - - $snapshotGainersLosers->get(); - - $this->assertPath($requestsContainer, '/v2/snapshot/locale/global/markets/forex/gainers'); - } - - public function testSnapshotAllTickersGetCall() { - $requestsContainer = []; - - $snapshotAllTickers = new SnapshotAllTickers('fake-api-key'); - $snapshotAllTickers->httpClient = $this->getHttpMock($requestsContainer, [ - 'tickers' => [], - ]); - - $snapshotAllTickers->get(); - - $this->assertPath($requestsContainer, '/v2/snapshot/locale/global/markets/forex/tickers'); - } - - private function getHttpMock(&$requestsContainer, $response=[]) { - - $mock = new MockHandler([ - new Response(200, [], json_encode($response)), - ]); - $handler = HandlerStack::create($mock); - - $history = Middleware::history($requestsContainer); - $handler->push($history); - - return new Client(['handler' => $handler]); - } - - private function assertPath($requests, $path) { - $this->assertCount(1, $requests); - $this->assertEquals($path, $requests[0]['request']->getUri()->getPath()); - } -} \ No newline at end of file diff --git a/tests/rest/ReferenceTest.php b/tests/rest/ReferenceTest.php deleted file mode 100644 index f2133fc..0000000 --- a/tests/rest/ReferenceTest.php +++ /dev/null @@ -1,182 +0,0 @@ -assertInstanceOf(Tickers::class, $reference->tickers); - $this->assertInstanceOf(TickerTypes::class, $reference->tickerTypes); - $this->assertInstanceOf(TickerDetails::class, $reference->tickerDetails); - $this->assertInstanceOf(TickerNews::class, $reference->tickerNews); - $this->assertInstanceOf(Markets::class, $reference->markets); - $this->assertInstanceOf(Locales::class, $reference->locales); - $this->assertInstanceOf(StockSplits::class, $reference->stockSplits); - $this->assertInstanceOf(StockDividends::class, $reference->stockDividends); - $this->assertInstanceOf(StockFinancials::class, $reference->stockFinancials); - $this->assertInstanceOf(MarketStatus::class, $reference->marketStatus); - $this->assertInstanceOf(MarketHolidays::class, $reference->marketHolidays); - } - - public function testTickersGetCall() { - $requestsContainer = []; - - $tickers = new Tickers('fake-api-key'); - $tickers->httpClient = $this->getHttpMock($requestsContainer); - - $tickers->get(); - - $this->assertPath($requestsContainer, '/v2/reference/tickers'); - } - - public function testTickerTypesGetCall() { - $requestsContainer = []; - - $tickerTypes = new TickerTypes('fake-api-key'); - $tickerTypes->httpClient = $this->getHttpMock($requestsContainer); - - $tickerTypes->get(); - - $this->assertPath($requestsContainer, '/v2/reference/types'); - } - - public function testTickerDetailsGetCall() { - $requestsContainer = []; - $response = [ - 'lei' => 'lei_remapped', - 'sic' => 'sic_remapped' - ]; - $tickerDetails = new TickerDetails('fake-api-key'); - $tickerDetails->httpClient = $this->getHttpMock($requestsContainer, $response); - - $apiResponse = $tickerDetails->get('AAPL'); - - $this->assertPath($requestsContainer, '/v1/meta/symbols/AAPL/company'); - $this->assertEquals('lei_remapped', $apiResponse['legalEntityIdentifier']); - $this->assertEquals('sic_remapped', $apiResponse['standardIndustryClassification']); - } - - public function testTickerNewsGetCall() { - $requestsContainer = []; - $tickerNews = new TickerNews('fake-api-key'); - $tickerNews->httpClient = $this->getHttpMock($requestsContainer); - - $tickerNews->get('AAPL'); - - $this->assertPath($requestsContainer, '/v1/meta/symbols/AAPL/news'); - } - - public function testMarketsGetCall() { - $requestsContainer = []; - - $markets = new Markets('fake-api-key'); - $markets->httpClient = $this->getHttpMock($requestsContainer); - - $markets->get(); - - $this->assertPath($requestsContainer, '/v2/reference/markets'); - } - - public function testLocalesGetCall() { - $requestsContainer = []; - - $locales = new Locales('fake-api-key'); - $locales->httpClient = $this->getHttpMock($requestsContainer); - - $locales->get(); - - $this->assertPath($requestsContainer, '/v2/reference/locales'); - } - - public function testStockSplitsCall() { - $requestsContainer = []; - - $stockSplits = new StockSplits('fake-api-key'); - $stockSplits->httpClient = $this->getHttpMock($requestsContainer); - - $stockSplits->get('AAPL'); - - $this->assertPath($requestsContainer, '/v2/reference/splits/AAPL'); - } - - public function testStockDividendsCall() { - $requestsContainer = []; - - $stockDividends = new StockDividends('fake-api-key'); - $stockDividends->httpClient = $this->getHttpMock($requestsContainer); - - $stockDividends->get('AAPL'); - - $this->assertPath($requestsContainer, '/v2/reference/dividends/AAPL'); - } - - public function testStockFinancialsCall() { - $requestsContainer = []; - - $stockFinancials = new StockFinancials('fake-api-key'); - $stockFinancials->httpClient = $this->getHttpMock($requestsContainer); - - $stockFinancials->get('AAPL'); - - $this->assertPath($requestsContainer, '/v2/reference/financials/AAPL'); - } - - public function testMarketStatusGetCall() { - $requestsContainer = []; - - $marketStatus = new MarketStatus('fake-api-key'); - $marketStatus->httpClient = $this->getHttpMock($requestsContainer); - - $marketStatus->get(); - - $this->assertPath($requestsContainer, '/v1/marketstatus/now'); - } - - public function testMarketHolidaysGetCall() { - $requestsContainer = []; - - $marketHolidays = new MarketHolidays('fake-api-key'); - $marketHolidays->httpClient = $this->getHttpMock($requestsContainer); - - $marketHolidays->get(); - - $this->assertPath($requestsContainer, '/v1/marketstatus/upcoming'); - } - - private function getHttpMock(&$requestsContainer, $response=[]) { - - $mock = new MockHandler([ - new Response(200, [], json_encode($response)), - ]); - $handler = HandlerStack::create($mock); - - $history = Middleware::history($requestsContainer); - $handler->push($history); - - return new Client(['handler' => $handler]); - } - - private function assertPath($requests, $path) { - $this->assertCount(1, $requests); - $this->assertEquals($path, $requests[0]['request']->getUri()->getPath()); - } - -} \ No newline at end of file diff --git a/tests/rest/StocksTest.php b/tests/rest/StocksTest.php deleted file mode 100644 index 2349d82..0000000 --- a/tests/rest/StocksTest.php +++ /dev/null @@ -1,293 +0,0 @@ -assertInstanceOf(Exchanges::class, $stocks->exchanges); - $this->assertInstanceOf(HistoricTrades::class, $stocks->historicTrades); - $this->assertInstanceOf(HistoricTradesV2::class, $stocks->historicTradesV2); - $this->assertInstanceOf(HistoricQuotes::class, $stocks->historicQuotes); - $this->assertInstanceOf(HistoricQuotesV2::class, $stocks->historicQuotesV2); - $this->assertInstanceOf(LastTradeForSymbol::class, $stocks->lastTradeForSymbol); - $this->assertInstanceOf(LastQuoteForSymbol::class, $stocks->lastQuoteForSymbol); - $this->assertInstanceOf(DailyOpenClose::class, $stocks->dailyOpenClose); - $this->assertInstanceOf(ConditionMappings::class, $stocks->conditionMappings); - $this->assertInstanceOf(SnapshotAllTickers::class, $stocks->snapshotAllTickers); - $this->assertInstanceOf(SnapshotSingleTicker::class, $stocks->snapshotSingleTicker); - $this->assertInstanceOf(SnapshotGainersLosers::class, $stocks->snapshotGainersLosers); - $this->assertInstanceOf(PreviousClose::class, $stocks->previousClose); - $this->assertInstanceOf(Aggregates::class, $stocks->aggregates); - $this->assertInstanceOf(GroupedDaily::class, $stocks->groupedDaily); - } - - public function testExchangesGetCall() { - $requestsContainer = []; - - $exchanges = new Exchanges('fake-api-key'); - $exchanges->httpClient = $this->getHttpMock($requestsContainer); - - $exchanges->get(); - - $this->assertPath($requestsContainer, '/v1/meta/exchanges'); - } - - public function testHistoricTradesGetCall() { - $requestsContainer = []; - - $historicTrades = new HistoricTrades('fake-api-key'); - $historicTrades->httpClient = $this->getHttpMock($requestsContainer, [ - 'ticks' => [], - ]); - - $historicTrades->get('AAPL', '2019-2-2'); - - $this->assertPath($requestsContainer, '/v1/historic/trades/AAPL/2019-2-2'); - - } - - public function testHistoricTradesV2GetCall() { - $requestsContainer = []; - - $historicTradesV2 = new HistoricTradesV2('fake-api-key'); - $historicTradesV2->httpClient = $this->getHttpMock($requestsContainer, [ - 'ticks' => [], - ]); - - $historicTradesV2->get('AAPL', '2019-2-2'); - - $this->assertPath($requestsContainer, '/v2/ticks/stocks/trades/AAPL/2019-2-2'); - - } - - public function testHistoricQuotesGetCall() { - $requestsContainer = []; - - $historicQuotes = new HistoricQuotes('fake-api-key'); - $historicQuotes->httpClient = $this->getHttpMock($requestsContainer, [ - 'ticks' => [], - ]); - - $historicQuotes->get('AAPL', '2019-2-2'); - - $this->assertPath($requestsContainer, '/v1/historic/quotes/AAPL/2019-2-2'); - } - - public function testHistoricQuotesV2GetCall() { - $requestsContainer = []; - - $historicQuotesV2 = new HistoricQuotesV2('fake-api-key'); - $historicQuotesV2->httpClient = $this->getHttpMock($requestsContainer, [ - 'results' => [], - ]); - - $historicQuotesV2->get('AAPL', '2019-2-2'); - - $this->assertPath($requestsContainer, '/v2/ticks/stocks/nbbo/AAPL/2019-2-2'); - } - - - public function testLastTradeForSymbolGetCall() { - $requestsContainer = []; - - $lastTradeForSymbol = new LastTradeForSymbol('fake-api-key'); - $lastTradeForSymbol->httpClient = $this->getHttpMock($requestsContainer); - - $lastTradeForSymbol->get('AAPL'); - - $this->assertPath($requestsContainer, '/v1/last/stocks/AAPL'); - } - - public function testLastQuoteForSymbolGetCall() { - $requestsContainer = []; - - $lastTradeForSymbol = new LastQuoteForSymbol('fake-api-key'); - $lastTradeForSymbol->httpClient = $this->getHttpMock($requestsContainer); - - $lastTradeForSymbol->get('AAPL'); - - $this->assertPath($requestsContainer, '/v1/last_quote/stocks/AAPL'); - } - - public function testDailyOpenCloseGetCall() { - $requestsContainer = []; - - $dailyOpenClose = new DailyOpenClose('fake-api-key'); - $dailyOpenClose->httpClient = $this->getHttpMock($requestsContainer); - - $dailyOpenClose->get('AAPL', '2019-2-2'); - - $this->assertPath($requestsContainer, '/v1/open-close/AAPL/2019-2-2'); - } - - public function testConditionMappingsGetCall() { - $requestsContainer = []; - - $conditionMappings = new ConditionMappings('fake-api-key'); - $conditionMappings->httpClient = $this->getHttpMock($requestsContainer); - - $conditionMappings->get(); - - $this->assertPath($requestsContainer, '/v1/meta/conditions/trades'); - } - - public function testSnapshotAllTickersGetCall() { - $requestsContainer = []; - - $snapshotAllTickers = new SnapshotAllTickers('fake-api-key'); - $snapshotAllTickers->httpClient = $this->getHttpMock($requestsContainer, [ - 'tickers' => [], - ]); - - $snapshotAllTickers->get(); - - $this->assertPath($requestsContainer, '/v2/snapshot/locale/us/markets/stocks/tickers'); - } - - public function testSnapshotSingleTickerGetCall() { - $requestsContainer = []; - - $singleTicker = new SnapshotSingleTicker('fake-api-key'); - - $singleTicker->httpClient = $this->getHttpMock($requestsContainer, [ - 'ticker' => [ - 'day' => [ - 'c' => 'c', - 'h' => 'h', - 'l' => 'l', - 'o' => 'o', - 'v' => 'v', - ], - 'lastTrade' => [ - 'c1' => 'c1', - 'c2' => 'c2', - 'c3' => 'c3', - 'c4' => 'c4', - 'e' => 'e', - 'p' => 'p', - 's' => 's', - 't' => 't', - ], - 'lastQuote' => [ - 'p' => 'p', - 's' => 's', - 'S' => 'S', - 'P' => 'P', - 't' => 't', - ], - 'min' => [ - 'c' => 'c', - 'h' => 'h', - 'l' => 'l', - 'o' => 'o', - 'v' => 'v', - ], - 'prevDay' => [ - 'c' => 'c', - 'h' => 'h', - 'l' => 'l', - 'o' => 'o', - 'v' => 'v', - ], - ], - ]); - - $singleTicker->get('AAPL'); - - $this->assertPath($requestsContainer, '/v2/snapshot/locale/us/markets/stocks/tickers/AAPL'); - } - - public function testSnapshotGainersLosersGetCall() { - $requestsContainer = []; - - $snapshotGainersLosers = new SnapshotGainersLosers('fake-api-key'); - $snapshotGainersLosers->httpClient = $this->getHttpMock($requestsContainer, [ - 'tickers' => [], - ]); - - $snapshotGainersLosers->get(); - - $this->assertPath($requestsContainer, '/v2/snapshot/locale/us/markets/stocks/gainers'); - } - - public function testPreviousCloseGetCall() { - $requestsContainer = []; - - $previousClose = new PreviousClose('fake-api-key'); - $previousClose->httpClient = $this->getHttpMock($requestsContainer, [ - 'results' => [], - ]); - - $previousClose->get('AAPL'); - - $this->assertPath($requestsContainer, '/v2/aggs/ticker/AAPL/prev'); - } - - public function testAggregatesCloseGetCall() { - $requestsContainer = []; - - $previousClose = new Aggregates('fake-api-key'); - $previousClose->httpClient = $this->getHttpMock($requestsContainer, [ - 'results' => [], - ]); - - $previousClose->get('AAPL', 1, '2018-2-2', '2019-2-2'); - - $this->assertPath($requestsContainer, '/v2/aggs/ticker/AAPL/range/1/days/2018-2-2/2019-2-2'); - } - - public function testGroupedDailyGetCall() { - $requestsContainer = []; - - $groupedDaily = new GroupedDaily('fake-api-key'); - $groupedDaily->httpClient = $this->getHttpMock($requestsContainer, [ - 'results' => [], - ]); - - $groupedDaily->get('2019-2-2'); - - $this->assertPath($requestsContainer, '/v2/aggs/grouped/locale/US/market/STOCKS/2019-2-2'); - } - - private function getHttpMock(&$requestsContainer, $response=[]) { - - $mock = new MockHandler([ - new Response(200, [], json_encode($response)), - ]); - $handler = HandlerStack::create($mock); - - $history = Middleware::history($requestsContainer); - $handler->push($history); - - return new Client(['handler' => $handler]); - } - - private function assertPath($requests, $path) { - $this->assertCount(1, $requests); - $this->assertEquals($path, $requests[0]['request']->getUri()->getPath()); - } -} \ No newline at end of file