@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | /** |
50 | 50 | * @var array |
51 | 51 | */ |
52 | - private $argv = array (); |
|
52 | + private $argv = array(); |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * @var \Classes\AdapterConfig\AbstractAdapter |
@@ -61,18 +61,18 @@ discard block |
||
61 | 61 | */ |
62 | 62 | private $adapterDriver; |
63 | 63 | |
64 | - public function __construct ( $argv , $basePath ) |
|
64 | + public function __construct($argv, $basePath) |
|
65 | 65 | { |
66 | - if ( array_key_exists ( 'help' , $argv ) ) |
|
66 | + if (array_key_exists('help', $argv)) |
|
67 | 67 | { |
68 | - die ( $this->getUsage () ); |
|
68 | + die ($this->getUsage()); |
|
69 | 69 | } |
70 | - if ( array_key_exists ( 'status' , $argv ) ) |
|
70 | + if (array_key_exists('status', $argv)) |
|
71 | 71 | { |
72 | - $argv[ 'status' ] = true; |
|
72 | + $argv['status'] = true; |
|
73 | 73 | } |
74 | 74 | |
75 | - $this->argv = $this->parseConfig ( $basePath , $argv ); |
|
75 | + $this->argv = $this->parseConfig($basePath, $argv); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return string |
82 | 82 | */ |
83 | - public function getUsage () |
|
83 | + public function getUsage() |
|
84 | 84 | { |
85 | 85 | $version = static::$version; |
86 | 86 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | EOF; |
106 | 106 | } |
107 | 107 | |
108 | - public function getVersion () |
|
108 | + public function getVersion() |
|
109 | 109 | { |
110 | 110 | $version = static::$version; |
111 | 111 | |
@@ -121,22 +121,22 @@ discard block |
||
121 | 121 | * @return array |
122 | 122 | * @throws \Exception |
123 | 123 | */ |
124 | - private function parseConfig ( $basePath , $argv ) |
|
124 | + private function parseConfig($basePath, $argv) |
|
125 | 125 | { |
126 | - $this->_basePath = dirname ( $basePath ); |
|
126 | + $this->_basePath = dirname($basePath); |
|
127 | 127 | |
128 | - $configIni = isset( $argv[ 'config-ini' ] ) ? $argv[ 'config-ini' ] |
|
128 | + $configIni = isset($argv['config-ini']) ? $argv['config-ini'] |
|
129 | 129 | : $this->_basePath . $this->configIniDefault; |
130 | 130 | |
131 | - $configTemp = $this->loadIniFile ( realpath ( $configIni ) ); |
|
132 | - $configCurrent = self::parseConfigEnv ( $configTemp , $argv ); |
|
131 | + $configTemp = $this->loadIniFile(realpath($configIni)); |
|
132 | + $configCurrent = self::parseConfigEnv($configTemp, $argv); |
|
133 | 133 | |
134 | - if ( ! isset( $configCurrent[ 'framework' ] ) ) |
|
134 | + if ( ! isset($configCurrent['framework'])) |
|
135 | 135 | { |
136 | - throw new \Exception( "configure which framework you want to use! \n" ); |
|
136 | + throw new \Exception("configure which framework you want to use! \n"); |
|
137 | 137 | } |
138 | 138 | |
139 | - return $argv + array_filter ( $configCurrent ); |
|
139 | + return $argv + array_filter($configCurrent); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -146,22 +146,22 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return string |
148 | 148 | */ |
149 | - private static function parseConfigEnv ( $configTemp , $argv ) |
|
149 | + private static function parseConfigEnv($configTemp, $argv) |
|
150 | 150 | { |
151 | - $thisSection = isset( $configTemp[ key ( $configTemp ) ][ 'config-env' ] ) ? |
|
152 | - $configTemp[ key ( $configTemp ) ][ 'config-env' ] : null; |
|
151 | + $thisSection = isset($configTemp[key($configTemp)]['config-env']) ? |
|
152 | + $configTemp[key($configTemp)]['config-env'] : null; |
|
153 | 153 | |
154 | - $thisSection = isset( $argv[ 'config-env' ] ) ? $argv[ 'config-env' ] |
|
154 | + $thisSection = isset($argv['config-env']) ? $argv['config-env'] |
|
155 | 155 | : $thisSection; |
156 | 156 | |
157 | - if ( isset( $configTemp[ $thisSection ][ 'extends' ] ) ) |
|
157 | + if (isset($configTemp[$thisSection]['extends'])) |
|
158 | 158 | { |
159 | 159 | #faz marge da config principal com a config extendida |
160 | - return $configTemp[ $thisSection ] |
|
161 | - + $configTemp[ $configTemp[ $thisSection ][ 'extends' ] ]; |
|
160 | + return $configTemp[$thisSection] |
|
161 | + + $configTemp[$configTemp[$thisSection]['extends']]; |
|
162 | 162 | } |
163 | 163 | |
164 | - return $configTemp[ key ( $configTemp ) ]; |
|
164 | + return $configTemp[key($configTemp)]; |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -175,32 +175,32 @@ discard block |
||
175 | 175 | * @throws \Exception |
176 | 176 | * @return array |
177 | 177 | */ |
178 | - protected function loadIniFile ( $filename ) |
|
178 | + protected function loadIniFile($filename) |
|
179 | 179 | { |
180 | - if ( ! is_file ( $filename ) ) |
|
180 | + if ( ! is_file($filename)) |
|
181 | 181 | { |
182 | - throw new \Exception( "configuration file does not exist! \n" ); |
|
182 | + throw new \Exception("configuration file does not exist! \n"); |
|
183 | 183 | } |
184 | 184 | |
185 | - $loaded = parse_ini_file ( $filename , true ); |
|
186 | - $iniArray = array (); |
|
187 | - foreach ( $loaded as $key => $data ) |
|
185 | + $loaded = parse_ini_file($filename, true); |
|
186 | + $iniArray = array(); |
|
187 | + foreach ($loaded as $key => $data) |
|
188 | 188 | { |
189 | - $pieces = explode ( $this->sectionSeparator , $key ); |
|
190 | - $thisSection = trim ( $pieces[ 0 ] ); |
|
191 | - switch ( count ( $pieces ) ) |
|
189 | + $pieces = explode($this->sectionSeparator, $key); |
|
190 | + $thisSection = trim($pieces[0]); |
|
191 | + switch (count($pieces)) |
|
192 | 192 | { |
193 | 193 | case 1: |
194 | - $iniArray[ $thisSection ] = $data; |
|
194 | + $iniArray[$thisSection] = $data; |
|
195 | 195 | break; |
196 | 196 | |
197 | 197 | case 2: |
198 | - $extendedSection = trim ( $pieces[ 1 ] ); |
|
199 | - $iniArray[ $thisSection ] = array_merge ( array ( 'extends' => $extendedSection ) , $data ); |
|
198 | + $extendedSection = trim($pieces[1]); |
|
199 | + $iniArray[$thisSection] = array_merge(array('extends' => $extendedSection), $data); |
|
200 | 200 | break; |
201 | 201 | |
202 | 202 | default: |
203 | - throw new \Exception( "Section '$thisSection' may not extend multiple sections in $filename" ); |
|
203 | + throw new \Exception("Section '$thisSection' may not extend multiple sections in $filename"); |
|
204 | 204 | } |
205 | 205 | } |
206 | 206 | |
@@ -212,14 +212,14 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @return \Classes\AdapterConfig\AbstractAdapter |
214 | 214 | */ |
215 | - private function factoryConfig () |
|
215 | + private function factoryConfig() |
|
216 | 216 | { |
217 | - switch ( strtolower ( $this->argv[ 'framework' ] ) ) |
|
217 | + switch (strtolower($this->argv['framework'])) |
|
218 | 218 | { |
219 | 219 | case 'none': |
220 | - return new None( $this->argv ); |
|
220 | + return new None($this->argv); |
|
221 | 221 | case 'zend_framework': |
222 | - return new ZendFrameworkOne( $this->argv ); |
|
222 | + return new ZendFrameworkOne($this->argv); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | } |
@@ -229,23 +229,23 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return \Classes\AdapterConfig\AbstractAdapter |
231 | 231 | */ |
232 | - private function factoryDriver () |
|
232 | + private function factoryDriver() |
|
233 | 233 | { |
234 | - $config = $this->getAdapterConfig (); |
|
235 | - switch ( $this->argv[ 'driver' ] ) |
|
234 | + $config = $this->getAdapterConfig(); |
|
235 | + switch ($this->argv['driver']) |
|
236 | 236 | { |
237 | 237 | case 'pgsql': |
238 | 238 | case 'pdo_pgsql': |
239 | - return new Pgsql( $config ); |
|
239 | + return new Pgsql($config); |
|
240 | 240 | case 'mysql': |
241 | 241 | case 'pdo_mysql': |
242 | - return new Mysql( $config ); |
|
242 | + return new Mysql($config); |
|
243 | 243 | case 'mssql': |
244 | - return new Mssql( $config ); |
|
244 | + return new Mssql($config); |
|
245 | 245 | case 'dblib': |
246 | - return new Dblib( $config ); |
|
246 | + return new Dblib($config); |
|
247 | 247 | case 'sqlsrv': |
248 | - return new Sqlsrv( $config ); |
|
248 | + return new Sqlsrv($config); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | } |
@@ -253,11 +253,11 @@ discard block |
||
253 | 253 | /** |
254 | 254 | * @return AdapterConfig\AbstractAdapter |
255 | 255 | */ |
256 | - public function getAdapterConfig () |
|
256 | + public function getAdapterConfig() |
|
257 | 257 | { |
258 | - if ( ! $this->adapterConfig ) |
|
258 | + if ( ! $this->adapterConfig) |
|
259 | 259 | { |
260 | - $this->adapterConfig = $this->factoryConfig (); |
|
260 | + $this->adapterConfig = $this->factoryConfig(); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | return $this->adapterConfig; |
@@ -266,11 +266,11 @@ discard block |
||
266 | 266 | /** |
267 | 267 | * @return AdaptersDriver\AbsractAdapter |
268 | 268 | */ |
269 | - public function getAdapterDriver () |
|
269 | + public function getAdapterDriver() |
|
270 | 270 | { |
271 | - if ( ! $this->adapterDriver ) |
|
271 | + if ( ! $this->adapterDriver) |
|
272 | 272 | { |
273 | - $this->adapterDriver = $this->factoryDriver (); |
|
273 | + $this->adapterDriver = $this->factoryDriver(); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | return $this->adapterDriver; |