1 | <?php |
||
10 | abstract class Driver implements DriverContract |
||
11 | { |
||
12 | /** @var Collection */ |
||
13 | protected $parameters; |
||
14 | |||
15 | /** |
||
16 | * Get driver short name. |
||
17 | * |
||
18 | * This name is used as an alias for configuration. |
||
19 | * |
||
20 | * @return string |
||
21 | */ |
||
22 | public function getShortName(): string |
||
23 | { |
||
24 | $shortName = explode('\\', get_class($this)); |
||
25 | |||
26 | return collect($shortName)->last(); |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * Initialize driver. |
||
31 | * |
||
32 | * @param Collection $parameters |
||
33 | * |
||
34 | * @return Driver|DriverContract|static |
||
35 | */ |
||
36 | 1 | public function initialize(Collection $parameters): DriverContract |
|
37 | { |
||
38 | 1 | foreach ($this->getDefaultParameters() as $key => $value) { |
|
39 | 1 | $value = $parameters->get($key, $value); |
|
40 | |||
41 | 1 | $parameters->put($key, $value); |
|
42 | } |
||
43 | |||
44 | 1 | $this->parameters = collect($parameters); |
|
45 | |||
46 | 1 | return $this; |
|
47 | } |
||
48 | |||
49 | /** |
||
50 | * Get driver parameters. |
||
51 | * |
||
52 | * @return Collection |
||
53 | */ |
||
54 | public function getParameters(): Collection |
||
58 | } |
||
59 |