1 | <?php |
||
20 | class ConfigManager extends Repository |
||
21 | { |
||
22 | /** |
||
23 | * the config file name of this package. |
||
24 | */ |
||
25 | const CONFIG_FILE_NAME = 'url-shortener'; |
||
26 | |||
27 | /** |
||
28 | * load the configuration files. |
||
29 | */ |
||
30 | public function __construct() |
||
36 | |||
37 | /** |
||
38 | * extend the functionality of the default get() of the Repository |
||
39 | * but always prepend the keys with the config file name. |
||
40 | * |
||
41 | * @param $key |
||
42 | * |
||
43 | * @return mixed |
||
44 | */ |
||
45 | public function read($key) |
||
49 | |||
50 | /** |
||
51 | * helper function to return the driver default name. |
||
52 | * |
||
53 | * @return mixed |
||
54 | */ |
||
55 | public function driverName() |
||
59 | |||
60 | /** |
||
61 | * helper function to return the parameters of the driver $name. |
||
62 | * |
||
63 | * @param $name |
||
64 | * |
||
65 | * @return mixed |
||
66 | */ |
||
67 | public function driverParameters($name) |
||
71 | |||
72 | /** |
||
73 | * Initialize the paths. |
||
74 | * check if this package is used inside of laravel project, |
||
75 | * if it is laravel project then try to load the config file |
||
76 | * from the laravel config directory. |
||
77 | * if the file was not found (not published) ten load the config |
||
78 | * file form the package directory. |
||
79 | * |
||
80 | * @return string |
||
81 | */ |
||
82 | private function configurationPath() |
||
100 | |||
101 | /** |
||
102 | * Load the configuration items from all of the files. |
||
103 | * |
||
104 | * @param $path |
||
105 | */ |
||
106 | private function loadConfigurationFiles($path) |
||
122 | |||
123 | /** |
||
124 | * Get the configuration files for the selected environment. |
||
125 | * |
||
126 | * @return array |
||
127 | */ |
||
128 | private function getConfigurationFiles() |
||
145 | } |
||
146 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: