Issues (16)

src/LaravelCryptoStats.php (2 issues)

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
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
        $this->config = /** @scrutinizer ignore-call */ config('laravel_crypto_stats');
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
$instance is of type LaravelCryptoStats\connector, thus it always evaluated to true.
Loading history...
37
            throw new Exception('Instance of the LaravelCryptoStats API connector was not created!');
38
        }
39
40
        return $instance->$method(...$parameters);
41
    }
42
}
43