1 | <?php |
||
14 | trait HasConfig |
||
15 | { |
||
16 | /* ----------------------------------------------------------------- |
||
17 | | Properties |
||
18 | | ----------------------------------------------------------------- |
||
19 | */ |
||
20 | |||
21 | /** |
||
22 | * Merge multiple config files into one instance (package name as root key) |
||
23 | * |
||
24 | * @var bool |
||
25 | */ |
||
26 | protected $multiConfigs = false; |
||
27 | |||
28 | /* ----------------------------------------------------------------- |
||
29 | | Main Methods |
||
30 | | ----------------------------------------------------------------- |
||
31 | */ |
||
32 | |||
33 | /** |
||
34 | * Get config folder. |
||
35 | * |
||
36 | * @return string |
||
37 | */ |
||
38 | protected function getConfigFolder(): string |
||
42 | |||
43 | /** |
||
44 | * Get config key. |
||
45 | * |
||
46 | * @param bool $withVendor |
||
47 | * @param string $separator |
||
48 | * |
||
49 | * @return string |
||
50 | */ |
||
51 | 18 | protected function getConfigKey(bool $withVendor = false, string $separator = '.'): string |
|
59 | |||
60 | /** |
||
61 | * Get config file path. |
||
62 | * |
||
63 | * @return string |
||
64 | */ |
||
65 | 18 | protected function getConfigFile(): string |
|
69 | |||
70 | /** |
||
71 | * Get the config files (paths). |
||
72 | * |
||
73 | * @return array|false |
||
74 | */ |
||
75 | protected function configFilesPaths() |
||
79 | |||
80 | /** |
||
81 | * Register configs. |
||
82 | * |
||
83 | * @param string $separator |
||
84 | */ |
||
85 | 18 | protected function registerConfig(string $separator = '.'): void |
|
91 | |||
92 | /** |
||
93 | * Register a single config file. |
||
94 | */ |
||
95 | 18 | protected function registerSingleConfig(): void |
|
99 | |||
100 | /** |
||
101 | * Register all package configs. |
||
102 | * |
||
103 | * @param string $separator |
||
104 | */ |
||
105 | protected function registerMultipleConfigs(string $separator = '.'): void |
||
113 | |||
114 | /** |
||
115 | * Publish the config file. |
||
116 | * |
||
117 | * @param string|null $path |
||
118 | */ |
||
119 | protected function publishConfig(?string $path = null): void |
||
125 | |||
126 | /** |
||
127 | * Publish a single config file. |
||
128 | * |
||
129 | * @param string|null $path |
||
130 | */ |
||
131 | protected function publishSingleConfig(?string $path = null): void |
||
137 | |||
138 | /** |
||
139 | * Publish multiple config files. |
||
140 | */ |
||
141 | protected function publishMultipleConfigs(): void |
||
152 | } |
||
153 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.