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