1 | <?php |
||
15 | trait HasConfig |
||
16 | { |
||
17 | /* ----------------------------------------------------------------- |
||
18 | | Properties |
||
19 | | ----------------------------------------------------------------- |
||
20 | */ |
||
21 | |||
22 | /** |
||
23 | * Merge multiple config files into one instance (package name as root key) |
||
24 | * |
||
25 | * @var bool |
||
26 | */ |
||
27 | protected $multiConfigs = false; |
||
28 | |||
29 | /* ----------------------------------------------------------------- |
||
30 | | Main Methods |
||
31 | | ----------------------------------------------------------------- |
||
32 | */ |
||
33 | |||
34 | /** |
||
35 | * Get config folder. |
||
36 | * |
||
37 | * @return string |
||
38 | */ |
||
39 | protected function getConfigFolder(): string |
||
43 | |||
44 | /** |
||
45 | * Get config key. |
||
46 | * |
||
47 | * @param bool $withVendor |
||
48 | * @param string $separator |
||
49 | * |
||
50 | * @return string |
||
51 | */ |
||
52 | 18 | protected function getConfigKey(bool $withVendor = false, string $separator = '.'): string |
|
60 | |||
61 | /** |
||
62 | * Get config file path. |
||
63 | * |
||
64 | * @return string |
||
65 | */ |
||
66 | 18 | protected function getConfigFile(): string |
|
70 | |||
71 | /** |
||
72 | * Get the config files (paths). |
||
73 | * |
||
74 | * @return array|false |
||
75 | */ |
||
76 | protected function configFilesPaths() |
||
80 | |||
81 | /** |
||
82 | * Register configs. |
||
83 | * |
||
84 | * @param string $separator |
||
85 | */ |
||
86 | 18 | protected function registerConfig(string $separator = '.'): void |
|
92 | |||
93 | /** |
||
94 | * Register a single config file. |
||
95 | */ |
||
96 | 18 | protected function registerSingleConfig(): void |
|
100 | |||
101 | /** |
||
102 | * Register all package configs. |
||
103 | * |
||
104 | * @param string $separator |
||
105 | */ |
||
106 | protected function registerMultipleConfigs(string $separator = '.'): void |
||
114 | |||
115 | /** |
||
116 | * Publish the config file. |
||
117 | * |
||
118 | * @param string|null $path |
||
119 | */ |
||
120 | protected function publishConfig(?string $path = null): void |
||
126 | |||
127 | /** |
||
128 | * Publish a single config file. |
||
129 | * |
||
130 | * @param string|null $path |
||
131 | */ |
||
132 | protected function publishSingleConfig(?string $path = null): void |
||
138 | |||
139 | /** |
||
140 | * Publish multiple config files. |
||
141 | */ |
||
142 | protected function publishMultipleConfigs(): void |
||
153 | } |
||
154 |
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.