1 | <?php |
||
7 | final class Aggregator |
||
8 | { |
||
9 | /** |
||
10 | * @var array |
||
11 | */ |
||
12 | protected $drivers; |
||
13 | |||
14 | /** |
||
15 | * Welcome |
||
16 | */ |
||
17 | 3 | public function __construct() |
|
21 | |||
22 | /** |
||
23 | * Set driver instance |
||
24 | * |
||
25 | * @param string $name |
||
26 | * @param mixed $driver |
||
27 | * @throws \DeGraciaMathieu\Manager\Exceptions\DriverOverwrittenException |
||
28 | * |
||
29 | * @return void |
||
30 | */ |
||
31 | 2 | public function set(string $name, $driver) |
|
32 | { |
||
33 | 2 | if ($this->has($name)) { |
|
34 | throw new DriverOverwrittenException('Driver [' . $name . '] already registered.'); |
||
35 | } |
||
36 | |||
37 | 2 | $this->drivers[$name] = $driver; |
|
38 | 2 | } |
|
39 | |||
40 | /** |
||
41 | * Get driver instance |
||
42 | * |
||
43 | * @param string $name |
||
44 | * |
||
45 | * @return mixed |
||
46 | */ |
||
47 | 2 | public function get(string $name) |
|
51 | |||
52 | /** |
||
53 | * Check if driver instance exists |
||
54 | * |
||
55 | * @param string $name |
||
56 | * |
||
57 | * @return boolean |
||
58 | */ |
||
59 | 2 | public function has(string $name) |
|
63 | |||
64 | /** |
||
65 | * Get all drivers instance |
||
66 | * |
||
67 | * @return array |
||
68 | */ |
||
69 | 1 | public function all(): array |
|
73 | } |
||
74 |