Skip to content

Commit

Permalink
Namespace fix (#10)
Browse files Browse the repository at this point in the history
- Replaced namespaces and folder structure for the entire package.
- Removed direct composer autoload from files. (no idea why autoloader was directly loaded)
  • Loading branch information
ersin-demirtas authored Mar 18, 2021
1 parent 867df03 commit 362a00f
Show file tree
Hide file tree
Showing 60 changed files with 241 additions and 217 deletions.
5 changes: 2 additions & 3 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<phpunit>
<testsuite name='polygon.io'>
<directory suffix='.php'>./src</directory>
<directory suffix='.php'>./tests</directory>
<directory suffix='Test.php'>./tests</directory>
</testsuite>
</phpunit>
</phpunit>
5 changes: 2 additions & 3 deletions src/Polygon.php → src/PolygonIO.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?php
namespace PolygonIO;
require_once __DIR__.'/../vendor/autoload.php';

use PolygonIO\rest\Rest;
use PolygonIO\Rest\Rest;
use PolygonIO\websockets\Websockets;

class PolygonIO {
Expand All @@ -20,4 +19,4 @@ public function __construct($apiKey)
$this->rest = new Rest($apiKey);
$this->websockets = new Websockets($apiKey);
}
}
}
4 changes: 2 additions & 2 deletions src/rest/common/Mappers.php → src/Rest/Common/Mappers.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace PolygonIO\rest;
namespace PolygonIO\Rest\Common;

class Mappers {
public static function quoteV1 ($tick) {
Expand Down Expand Up @@ -86,4 +86,4 @@ public static function cryptoSnapshotBookItem ($item) {
$item['price'] = $item['p'];
return $item;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
namespace PolygonIO\rest\crypto;
namespace PolygonIO\Rest\Crypto;

use PolygonIO\rest\Mappers;
use PolygonIO\rest\RestResource;
use PolygonIO\Rest\Common\Mappers;
use PolygonIO\Rest\RestResource;

class Aggregates extends RestResource {
public function get($tickerSymbol, $multiplier, $from, $to, $timespan = 'days', $params = []){
Expand All @@ -16,4 +16,4 @@ protected function mapper($response)
}, $response['results']);
return $response;
}
}
}
4 changes: 2 additions & 2 deletions src/rest/crypto/Crypto.php → src/Rest/Crypto/Crypto.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace PolygonIO\rest\crypto;
namespace PolygonIO\Rest\Crypto;

class Crypto {
public $aggregates;
Expand Down Expand Up @@ -28,4 +28,4 @@ public function __construct($apiKey)
$this->snapshotSingleTicker = new SnapshotSingleTicker($apiKey);
$this->snapshotSingleTickerFullBook = new SnapshotSingleTickerFullBook($apiKey);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php
namespace PolygonIO\rest\crypto;
namespace PolygonIO\Rest\Crypto;

use PolygonIO\rest\RestResource;
use PolygonIO\Rest\RestResource;

class CryptoExchanges extends RestResource {
public $route = '/v1/meta/crypto-exchanges';
public function get() {
return $this->_get($this->route);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
namespace PolygonIO\rest\crypto;
namespace PolygonIO\Rest\Crypto;

use PolygonIO\rest\Mappers;
use PolygonIO\rest\RestResource;
use PolygonIO\Rest\Common\Mappers;
use PolygonIO\Rest\RestResource;

class DailyOpenClose extends RestResource {
public function get($from, $to, $date){
Expand All @@ -19,4 +19,4 @@ protected function mapper($response)
}
return $response;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
namespace PolygonIO\rest\crypto;
namespace PolygonIO\Rest\Crypto;

use PolygonIO\rest\Mappers;
use PolygonIO\rest\RestResource;
use PolygonIO\Rest\Common\Mappers;
use PolygonIO\Rest\RestResource;

class GroupedDaily extends RestResource {
public function get($date, $locale = 'US', $market = 'CRYPTO', $params = []){
Expand All @@ -16,4 +16,4 @@ protected function mapper($response)
}, $response['results']);
return $response;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
namespace PolygonIO\rest\crypto;
namespace PolygonIO\Rest\Crypto;

use PolygonIO\rest\Mappers;
use PolygonIO\rest\RestResource;
use PolygonIO\Rest\Common\Mappers;
use PolygonIO\Rest\RestResource;

class HistoricCryptoTrade extends RestResource {
protected $defaultParams = [
Expand All @@ -20,4 +20,4 @@ protected function mapper($response)
}, $response['ticks']);
return $response;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
namespace PolygonIO\rest\crypto;
namespace PolygonIO\Rest\Crypto;

use PolygonIO\rest\RestResource;
use PolygonIO\Rest\RestResource;

class LastTradeForCryptoPair extends RestResource {
public function get($from, $to) {
return $this->_get('/v1/last/crypto/'.$from.'/'.$to);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
namespace PolygonIO\rest\stocks;
namespace PolygonIO\Rest\Crypto;

use PolygonIO\rest\Mappers;
use PolygonIO\rest\RestResource;
use PolygonIO\Rest\Common\Mappers;
use PolygonIO\Rest\RestResource;

class PreviousClose extends RestResource {
public function get($tickerSymbol, $params = []){
Expand All @@ -16,4 +16,4 @@ protected function mapper($response)
}, $response['results']);
return $response;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
namespace PolygonIO\rest\crypto;
namespace PolygonIO\Rest\Crypto;

use PolygonIO\rest\Mappers;
use PolygonIO\rest\RestResource;
use PolygonIO\Rest\Common\Mappers;
use PolygonIO\Rest\RestResource;

class SnapshotAllTickers extends RestResource {
public function get() {
Expand All @@ -16,4 +16,4 @@ protected function mapper($response)
}, $response['tickers']);
return $response;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
namespace PolygonIO\rest\crypto;
namespace PolygonIO\Rest\Crypto;

use PolygonIO\rest\Mappers;
use PolygonIO\rest\RestResource;
use PolygonIO\Rest\Common\Mappers;
use PolygonIO\Rest\RestResource;

class SnapshotGainersLosers extends RestResource {
public function get($direction = 'gainers') {
Expand All @@ -16,4 +16,4 @@ protected function mapper($response)
}, $response['tickers']);
return $response;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
namespace PolygonIO\rest\crypto;
namespace PolygonIO\Rest\Crypto;

use PolygonIO\rest\Mappers;
use PolygonIO\rest\RestResource;
use PolygonIO\Rest\Common\Mappers;
use PolygonIO\Rest\RestResource;

class SnapshotSingleTicker extends RestResource {
public function get($tickerSymbol) {
Expand All @@ -14,4 +14,4 @@ protected function mapper($response)
$response['ticker'] = Mappers::snapshotCryptoTicker($response['ticker']);
return $response;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
namespace PolygonIO\rest\crypto;
namespace PolygonIO\Rest\Crypto;

use PolygonIO\rest\Mappers;
use PolygonIO\rest\RestResource;
use PolygonIO\Rest\Common\Mappers;
use PolygonIO\Rest\RestResource;

class SnapshotSingleTickerFullBook extends RestResource {
public function get($tickerSymbol) {
Expand All @@ -23,4 +23,4 @@ protected function mapper($response)
}
return $response;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
namespace PolygonIO\rest\stocks;
namespace PolygonIO\Rest\Forex;

use PolygonIO\rest\Mappers;
use PolygonIO\rest\RestResource;
use PolygonIO\Rest\Common\Mappers;
use PolygonIO\Rest\RestResource;

class Aggregates extends RestResource {
public function get($tickerSymbol, $multiplier, $from, $to, $timespan = 'days', $params = []){
Expand All @@ -16,4 +16,4 @@ protected function mapper($response)
}, $response['results']);
return $response;
}
}
}
4 changes: 2 additions & 2 deletions src/rest/forex/Forex.php → src/Rest/Forex/Forex.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace PolygonIO\rest\forex;
namespace PolygonIO\Rest\Forex;

class Forex {
public $aggregates;
Expand All @@ -22,4 +22,4 @@ public function __construct($apiKey)
$this->snapshotAllTickers = new SnapshotAllTickers($apiKey);
$this->snapshotGainersLosers = new SnapshotGainersLosers($apiKey);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
namespace PolygonIO\rest\forex;
namespace PolygonIO\Rest\Forex;

use PolygonIO\rest\Mappers;
use PolygonIO\rest\RestResource;
use PolygonIO\Rest\Common\Mappers;
use PolygonIO\Rest\RestResource;

class GroupedDaily extends RestResource {
public function get($date, $locale = 'US', $market = 'FX', $params = []){
Expand All @@ -16,4 +16,4 @@ protected function mapper($response)
}, $response['results']);
return $response;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace PolygonIO\rest\forex;
namespace PolygonIO\Rest\Forex;

use PolygonIO\rest\RestResource;
use PolygonIO\Rest\RestResource;

class HistoricForexTick extends RestResource {
protected $defaultParams = [
Expand All @@ -11,4 +11,4 @@ class HistoricForexTick extends RestResource {
public function get($from, $to, $date, $params = []) {
return $this->_get('/v1/historic/forex/'.$from.'/'.$to.'/'.$date, $params);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
namespace PolygonIO\rest\forex;
namespace PolygonIO\Rest\Forex;

use PolygonIO\rest\RestResource;
use PolygonIO\Rest\RestResource;

class LastQuoteForCurrencyPair extends RestResource {
public function get($from, $to) {
return $this->_get('/v1/last_quote/currencies/'.$from.'/'.$to);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
namespace PolygonIO\rest\crypto;
namespace PolygonIO\Rest\Forex;

use PolygonIO\rest\Mappers;
use PolygonIO\rest\RestResource;
use PolygonIO\Rest\Common\Mappers;
use PolygonIO\Rest\RestResource;

class PreviousClose extends RestResource {
public function get($tickerSymbol, $params = []){
Expand All @@ -16,4 +16,4 @@ protected function mapper($response)
}, $response['results']);
return $response;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace PolygonIO\rest\forex;
namespace PolygonIO\Rest\Forex;

use PolygonIO\rest\RestResource;
use PolygonIO\Rest\RestResource;

class RealTimeCurrencyConversion extends RestResource {
protected $defaultParams = [
Expand All @@ -12,4 +12,4 @@ class RealTimeCurrencyConversion extends RestResource {
public function get($from, $to, $params = []) {
return $this->_get('/v1/conversion/'.$from.'/'.$to, $params);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
namespace PolygonIO\rest\forex;
namespace PolygonIO\Rest\Forex;

use PolygonIO\rest\Mappers;
use PolygonIO\rest\RestResource;
use PolygonIO\Rest\Common\Mappers;
use PolygonIO\Rest\RestResource;

class SnapshotAllTickers extends RestResource {
public function get() {
Expand All @@ -16,4 +16,4 @@ protected function mapper($response)
}, $response['tickers']);
return $response;
}
}
}
Loading

0 comments on commit 362a00f

Please sign in to comment.