Pashaster12 /
laravel-crypto-stats
| 1 | <?php |
||
| 2 | |||
| 3 | namespace LaravelCryptoStats; |
||
| 4 | |||
| 5 | use Exception; |
||
| 6 | use LaravelCryptoStats\Services\CurrencyManager; |
||
| 7 | |||
| 8 | class LaravelCryptoStats |
||
| 9 | { |
||
| 10 | use CurrencyManager; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * LaravelCryptoStats buider. |
||
| 14 | */ |
||
| 15 | public function __construct() |
||
| 16 | { |
||
| 17 | $this->config = config('laravel_crypto_stats'); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 18 | } |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Dynamically call the method of the API connector instance. |
||
| 22 | * |
||
| 23 | * @param string $method |
||
| 24 | * @param array $parameters |
||
| 25 | * |
||
| 26 | * @return mixed |
||
| 27 | */ |
||
| 28 | public function __call($method, $parameters) |
||
| 29 | { |
||
| 30 | if (!$this->currency) { |
||
| 31 | throw new Exception('Currency can not be null! Call setCurrency() for setting it.'); |
||
| 32 | } |
||
| 33 | $factory = new LaravelCryptoStatsFactory(); |
||
| 34 | $instance = $factory->getInstance($this->currency); |
||
| 35 | |||
| 36 | if (!$instance) { |
||
|
0 ignored issues
–
show
|
|||
| 37 | throw new Exception('Instance of the LaravelCryptoStats API connector was not created!'); |
||
| 38 | } |
||
| 39 | |||
| 40 | return $instance->$method(...$parameters); |
||
| 41 | } |
||
| 42 | } |
||
| 43 |