@@ -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,33 +231,33 @@ discard block |
||
| 231 | 231 | * |
| 232 | 232 | * @return \Classes\AdapterConfig\AbstractAdapter |
| 233 | 233 | */ |
| 234 | - private function factoryDriver () |
|
| 234 | + private function factoryDriver() |
|
| 235 | 235 | { |
| 236 | - switch ( $this->argv[ 'driver' ] ) |
|
| 236 | + switch ($this->argv['driver']) |
|
| 237 | 237 | { |
| 238 | 238 | case 'pgsql': |
| 239 | 239 | case 'pdo_pgsql': |
| 240 | - return new Pgsql( $this->getAdapterConfig () ); |
|
| 240 | + return new Pgsql($this->getAdapterConfig()); |
|
| 241 | 241 | case 'mysql': |
| 242 | 242 | case 'pdo_mysql': |
| 243 | - return new Mysql( $this->getAdapterConfig () ); |
|
| 243 | + return new Mysql($this->getAdapterConfig()); |
|
| 244 | 244 | case 'mssql': |
| 245 | - return new Mssql( $this->getAdapterConfig () ); |
|
| 245 | + return new Mssql($this->getAdapterConfig()); |
|
| 246 | 246 | case 'dblib': |
| 247 | - return new Dblib( $this->getAdapterConfig () ); |
|
| 247 | + return new Dblib($this->getAdapterConfig()); |
|
| 248 | 248 | case 'sqlsrv': |
| 249 | - return new Sqlsrv( $this->getAdapterConfig () ); |
|
| 249 | + return new Sqlsrv($this->getAdapterConfig()); |
|
| 250 | 250 | } |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
| 254 | 254 | * @return AdapterConfig\AbstractAdapter |
| 255 | 255 | */ |
| 256 | - public function getAdapterConfig () |
|
| 256 | + public function getAdapterConfig() |
|
| 257 | 257 | { |
| 258 | - if ( ! $this->adapterConfig instanceof AbstractAdapter ) |
|
| 258 | + if ( ! $this->adapterConfig instanceof AbstractAdapter) |
|
| 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; |