|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ultraleet\CurrencyRates; |
|
4
|
|
|
|
|
5
|
|
|
use Ultraleet\CurrencyRates\Contracts\Factory; |
|
6
|
|
|
use Ultraleet\CurrencyRates\Providers\DummyProvider; |
|
7
|
|
|
use Ultraleet\CurrencyRates\Providers\FixerProvider; |
|
8
|
|
|
use Illuminate\Support\Manager; |
|
9
|
|
|
use GuzzleHttp\Client as GuzzleClient; |
|
10
|
|
|
use Closure; |
|
11
|
|
|
|
|
12
|
|
|
class CurrencyRatesManager extends Manager implements Factory |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* The CurrencyRates factory instance. |
|
16
|
|
|
* |
|
17
|
|
|
* @var \Ultraleet\CurrencyRates\CurrencyRates |
|
18
|
|
|
*/ |
|
19
|
|
|
protected $factory; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Create a new manager instance. |
|
23
|
|
|
* |
|
24
|
|
|
* @param mixed |
|
25
|
|
|
* @return void |
|
26
|
|
|
*/ |
|
27
|
|
|
public function __construct($app) |
|
28
|
|
|
{ |
|
29
|
|
|
$this->app = $app; |
|
30
|
|
|
$this->factory = new CurrencyRates; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Get a driver instance. |
|
35
|
|
|
* |
|
36
|
|
|
* @param string $driver |
|
37
|
|
|
* @return mixed |
|
38
|
|
|
*/ |
|
39
|
|
|
public function driver($driver = null) |
|
40
|
|
|
{ |
|
41
|
|
|
return $this->factory->driver($driver); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Get the default driver name. |
|
46
|
|
|
* |
|
47
|
|
|
* @return string |
|
48
|
|
|
*/ |
|
49
|
|
|
public function getDefaultDriver() |
|
50
|
|
|
{ |
|
51
|
|
|
return $this->factory->getDefaultDriver(); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Set the default driver name. |
|
56
|
|
|
* |
|
57
|
|
|
* @param string |
|
58
|
|
|
*/ |
|
59
|
|
|
public function setDefaultDriver($name) |
|
60
|
|
|
{ |
|
61
|
|
|
$this->factory->setDefaultDriver($name); |
|
62
|
|
|
|
|
63
|
|
|
return $this; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Get all of the created drivers. |
|
68
|
|
|
* |
|
69
|
|
|
* @return array |
|
70
|
|
|
*/ |
|
71
|
|
|
public function getDrivers() |
|
72
|
|
|
{ |
|
73
|
|
|
return $this->factory->getDrivers(); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Register a custom driver creator Closure. |
|
78
|
|
|
* |
|
79
|
|
|
* @param string $driver |
|
80
|
|
|
* @param \Closure $callback |
|
81
|
|
|
* @return $this |
|
82
|
|
|
*/ |
|
83
|
|
|
public function extend($driver, Closure $callback) |
|
84
|
|
|
{ |
|
85
|
|
|
$this->factory->extend($driver, $callback); |
|
86
|
|
|
|
|
87
|
|
|
return $this; |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|