1 | <?php |
||
13 | trait HasConfig |
||
14 | { |
||
15 | /* ----------------------------------------------------------------- |
||
16 | | Properties |
||
17 | | ----------------------------------------------------------------- |
||
18 | */ |
||
19 | |||
20 | /** |
||
21 | * Merge multiple config files into one instance (package name as root key) |
||
22 | * |
||
23 | * @var bool |
||
24 | */ |
||
25 | protected $multiConfigs = false; |
||
26 | |||
27 | /* ----------------------------------------------------------------- |
||
28 | | Main Methods |
||
29 | | ----------------------------------------------------------------- |
||
30 | */ |
||
31 | |||
32 | /** |
||
33 | * Get config folder. |
||
34 | * |
||
35 | * @return string |
||
36 | */ |
||
37 | protected function getConfigFolder() |
||
41 | |||
42 | /** |
||
43 | * Get config key. |
||
44 | * |
||
45 | * @return string |
||
46 | */ |
||
47 | 6 | protected function getConfigKey() |
|
51 | |||
52 | /** |
||
53 | * Get config file path. |
||
54 | * |
||
55 | * @return string |
||
56 | */ |
||
57 | 6 | protected function getConfigFile() |
|
61 | |||
62 | /** |
||
63 | * Get config file destination path. |
||
64 | * |
||
65 | * @return string |
||
66 | */ |
||
67 | protected function getConfigFileDestination() |
||
71 | |||
72 | /** |
||
73 | * Register configs. |
||
74 | * |
||
75 | * @param string $separator |
||
76 | */ |
||
77 | 6 | protected function registerConfig($separator = '.') |
|
83 | |||
84 | /** |
||
85 | * Register all package configs. |
||
86 | * |
||
87 | * @param string $separator |
||
88 | */ |
||
89 | private function registerMultipleConfigs($separator = '.') |
||
97 | |||
98 | /** |
||
99 | * Publish the config file. |
||
100 | */ |
||
101 | protected function publishConfig() |
||
107 | } |
||
108 |
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.