@@ -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 | |
@@ -211,15 +211,15 @@ discard block |
||
211 | 211 | * analisa a opção e cria a instancia do Atapter do determinado framework |
212 | 212 | * |
213 | 213 | */ |
214 | - private function factoryConfig () |
|
214 | + private function factoryConfig() |
|
215 | 215 | { |
216 | - switch ( strtolower ( $this->argv[ 'framework' ] ) ) |
|
216 | + switch (strtolower($this->argv['framework'])) |
|
217 | 217 | { |
218 | 218 | case 'none': |
219 | - $this->adapterConfig = new None( $this->argv ); |
|
219 | + $this->adapterConfig = new None($this->argv); |
|
220 | 220 | break; |
221 | 221 | case 'zend_framework': |
222 | - $this->adapterConfig = new ZendFrameworkOne( $this->argv ); |
|
222 | + $this->adapterConfig = new ZendFrameworkOne($this->argv); |
|
223 | 223 | break; |
224 | 224 | } |
225 | 225 | |
@@ -230,23 +230,23 @@ discard block |
||
230 | 230 | * |
231 | 231 | * @return \Classes\AdapterConfig\AbstractAdapter |
232 | 232 | */ |
233 | - private function factoryDriver () |
|
233 | + private function factoryDriver() |
|
234 | 234 | { |
235 | - $config = $this->getAdapterConfig (); |
|
236 | - switch ( $this->argv[ 'driver' ] ) |
|
235 | + $config = $this->getAdapterConfig(); |
|
236 | + switch ($this->argv['driver']) |
|
237 | 237 | { |
238 | 238 | case 'pgsql': |
239 | 239 | case 'pdo_pgsql': |
240 | - return new Pgsql( $config ); |
|
240 | + return new Pgsql($config); |
|
241 | 241 | case 'mysql': |
242 | 242 | case 'pdo_mysql': |
243 | - return new Mysql( $config ); |
|
243 | + return new Mysql($config); |
|
244 | 244 | case 'mssql': |
245 | - return new Mssql( $config ); |
|
245 | + return new Mssql($config); |
|
246 | 246 | case 'dblib': |
247 | - return new Dblib( $config ); |
|
247 | + return new Dblib($config); |
|
248 | 248 | case 'sqlsrv': |
249 | - return new Sqlsrv( $config ); |
|
249 | + return new Sqlsrv($config); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | } |
@@ -254,11 +254,11 @@ discard block |
||
254 | 254 | /** |
255 | 255 | * @return AdapterConfig\AbstractAdapter |
256 | 256 | */ |
257 | - public function getAdapterConfig () |
|
257 | + public function getAdapterConfig() |
|
258 | 258 | { |
259 | - if ( ! $this->adapterConfig ) |
|
259 | + if ( ! $this->adapterConfig) |
|
260 | 260 | { |
261 | - $this->factoryConfig (); |
|
261 | + $this->factoryConfig(); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | return $this->adapterConfig; |
@@ -267,11 +267,11 @@ discard block |
||
267 | 267 | /** |
268 | 268 | * @return AdaptersDriver\AbsractAdapter |
269 | 269 | */ |
270 | - public function getAdapterDriver () |
|
270 | + public function getAdapterDriver() |
|
271 | 271 | { |
272 | - if ( ! $this->adapterDriver ) |
|
272 | + if ( ! $this->adapterDriver) |
|
273 | 273 | { |
274 | - $this->adapterDriver = $this->factoryDriver (); |
|
274 | + $this->adapterDriver = $this->factoryDriver(); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | return $this->adapterDriver; |