1 | <?php |
||
28 | class Config |
||
29 | { |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | public static $version = "1.3.1"; |
||
35 | |||
36 | /** |
||
37 | * String that separates the parent section name |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $sectionSeparator = ':'; |
||
42 | |||
43 | /** |
||
44 | * @var string |
||
45 | */ |
||
46 | private $configIniDefault = '/configs/config.ini'; |
||
47 | |||
48 | /** |
||
49 | * @var string |
||
50 | */ |
||
51 | public $_basePath; |
||
52 | /** |
||
53 | * @var array |
||
54 | */ |
||
55 | private $argv = array (); |
||
56 | |||
57 | /** |
||
58 | * @var \Classes\AdapterConfig\AbstractAdapter |
||
59 | */ |
||
60 | private $adapterConfig; |
||
61 | |||
62 | /** |
||
63 | * @var \Classes\AdaptersDriver\AbsractAdapter |
||
64 | */ |
||
65 | private $adapterDriver; |
||
66 | |||
67 | private $frameworkList = array ( |
||
68 | 'none', |
||
69 | 'zf1', |
||
70 | 'phalcon' |
||
71 | ); |
||
72 | |||
73 | public function __construct ( $argv, $basePath ) |
||
84 | |||
85 | /** |
||
86 | * Lista de ajuda quando digita 'help' |
||
87 | * |
||
88 | * @return string |
||
89 | */ |
||
90 | public function getUsage () |
||
114 | |||
115 | public function getVersion () |
||
121 | |||
122 | /** |
||
123 | * Analisa e estrutura a Configuracao do generate |
||
124 | * |
||
125 | * @param string $basePath |
||
126 | * @param array $argv |
||
127 | * |
||
128 | * @return array |
||
129 | * @throws \Exception |
||
130 | */ |
||
131 | private function parseConfig ( $basePath, $argv ) |
||
154 | |||
155 | /** |
||
156 | * |
||
157 | * @param $configTemp |
||
158 | * @param $argv |
||
159 | * |
||
160 | * @return string |
||
161 | */ |
||
162 | private static function parseConfigEnv ( $configTemp, $argv ) |
||
177 | |||
178 | /** |
||
179 | * Carregar o arquivo ini e pré-processa o separador de seção ':' |
||
180 | * no nome da seção (que é usado para a extensão seção) de modo a que a |
||
181 | * matriz resultante tem os nomes de seção corretos e as informações de |
||
182 | * extensão é armazenado em uma sub-ch ve |
||
183 | * |
||
184 | * @param string $filename |
||
185 | * |
||
186 | * @throws \Exception |
||
187 | * @return array |
||
188 | */ |
||
189 | protected function loadIniFile ( $filename ) |
||
217 | |||
218 | /** |
||
219 | * analisa a opção e cria a instancia do Atapter do determinado framework |
||
220 | * |
||
221 | * @return \Classes\AdapterConfig\AbstractAdapter |
||
222 | * |
||
223 | */ |
||
224 | private function factoryConfig () |
||
236 | |||
237 | /** |
||
238 | * Analisa a opção e instancia o determinado banco de dados |
||
239 | * |
||
240 | * @param AdapterConfig\AbstractAdapter $config |
||
241 | * |
||
242 | * @return AdaptersDriver\AbsractAdapter |
||
243 | */ |
||
244 | private function factoryDriver ( AdapterConfig\AbstractAdapter $config ) |
||
261 | |||
262 | /** |
||
263 | * @return AdapterConfig\AbstractAdapter |
||
264 | */ |
||
265 | public function getAdapterConfig () |
||
273 | |||
274 | /** |
||
275 | * @return AdaptersDriver\AbsractAdapter |
||
276 | */ |
||
277 | public function getAdapterDriver ( AdapterConfig\AbstractAdapter $config ) |
||
285 | |||
286 | } |
||
287 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.