@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | /** |
| 201 | 201 | * Retorna o Nome da Sequence da tabela |
| 202 | 202 | * |
| 203 | - * @param $table |
|
| 203 | + * @param string $table |
|
| 204 | 204 | * @param $column |
| 205 | 205 | * |
| 206 | 206 | * @return string |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * @param $nameTable |
| 250 | 250 | * @param int $schema |
| 251 | 251 | * |
| 252 | - * @return \Classes\Db\DbTable |
|
| 252 | + * @return AbsractAdapter |
|
| 253 | 253 | */ |
| 254 | 254 | public function createTable ( $nameTable, $schema = 0 ) |
| 255 | 255 | { |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | |
| 304 | 304 | /** |
| 305 | 305 | * @param string $nameTable |
| 306 | - * @param int|string $schema |
|
| 306 | + * @param integer $schema |
|
| 307 | 307 | * |
| 308 | 308 | * @return bool |
| 309 | 309 | */ |
@@ -103,31 +103,31 @@ discard block |
||
| 103 | 103 | $table = $this->getTable ( $table_name, $schema ); |
| 104 | 104 | if ( $table->hasColumn ( $constrant[ "column_name" ] ) ) { |
| 105 | 105 | $objConstrant = Constrant::getInstance () |
| 106 | - ->populate ( |
|
| 107 | - array ( |
|
| 108 | - 'constrant' => $constrant[ 'constraint_name' ], |
|
| 109 | - 'schema' => $constrant[ 'foreign_schema' ], |
|
| 110 | - 'table' => $constrant[ 'foreign_table' ], |
|
| 111 | - 'column' => $constrant[ 'foreign_column' ], |
|
| 112 | - 'database' => $this->database |
|
| 113 | - ) |
|
| 114 | - ); |
|
| 106 | + ->populate ( |
|
| 107 | + array ( |
|
| 108 | + 'constrant' => $constrant[ 'constraint_name' ], |
|
| 109 | + 'schema' => $constrant[ 'foreign_schema' ], |
|
| 110 | + 'table' => $constrant[ 'foreign_table' ], |
|
| 111 | + 'column' => $constrant[ 'foreign_column' ], |
|
| 112 | + 'database' => $this->database |
|
| 113 | + ) |
|
| 114 | + ); |
|
| 115 | 115 | |
| 116 | 116 | switch ( $constrant[ 'constraint_type' ] ) { |
| 117 | 117 | case "FOREIGN KEY": |
| 118 | 118 | $table->getColumn ( $constrant[ "column_name" ] ) |
| 119 | - ->addRefFk ( $objConstrant ); |
|
| 119 | + ->addRefFk ( $objConstrant ); |
|
| 120 | 120 | break; |
| 121 | 121 | case"PRIMARY KEY": |
| 122 | 122 | $table->getColumn ( $constrant[ "column_name" ] ) |
| 123 | - ->setPrimaryKey ( $objConstrant ) |
|
| 124 | - ->setSequence ( |
|
| 125 | - $this->getSequence ( |
|
| 126 | - $table_name, |
|
| 127 | - $constrant[ "column_name" ], |
|
| 128 | - $schema |
|
| 129 | - ) |
|
| 130 | - ); |
|
| 123 | + ->setPrimaryKey ( $objConstrant ) |
|
| 124 | + ->setSequence ( |
|
| 125 | + $this->getSequence ( |
|
| 126 | + $table_name, |
|
| 127 | + $constrant[ "column_name" ], |
|
| 128 | + $schema |
|
| 129 | + ) |
|
| 130 | + ); |
|
| 131 | 131 | break; |
| 132 | 132 | } |
| 133 | 133 | } |
@@ -145,13 +145,13 @@ discard block |
||
| 145 | 145 | $table = $this->getTable ( $table_name, $schema ); |
| 146 | 146 | if ( $table->hasColumn ( $constrant[ "foreign_column" ] ) ) { |
| 147 | 147 | $table->getColumn ( $constrant[ "foreign_column" ] ) |
| 148 | - ->createDependece ( |
|
| 149 | - $constrant[ 'constraint_name' ], |
|
| 150 | - $constrant[ 'table_name' ], |
|
| 151 | - $constrant[ 'column_name' ], |
|
| 152 | - $this->database, |
|
| 153 | - $constrant[ 'table_schema' ] |
|
| 154 | - ); |
|
| 148 | + ->createDependece ( |
|
| 149 | + $constrant[ 'constraint_name' ], |
|
| 150 | + $constrant[ 'table_name' ], |
|
| 151 | + $constrant[ 'column_name' ], |
|
| 152 | + $this->database, |
|
| 153 | + $constrant[ 'table_schema' ] |
|
| 154 | + ); |
|
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -183,10 +183,10 @@ discard block |
||
| 183 | 183 | ); |
| 184 | 184 | |
| 185 | 185 | $this->getTable ( $key, $schema ) |
| 186 | - ->addColumn ( $column ) |
|
| 187 | - ->setNamespace ( |
|
| 188 | - $this->config->createClassNamespace ( $this->getTable ( $key, $schema ) ) |
|
| 189 | - ); |
|
| 186 | + ->addColumn ( $column ) |
|
| 187 | + ->setNamespace ( |
|
| 188 | + $this->config->createClassNamespace ( $this->getTable ( $key, $schema ) ) |
|
| 189 | + ); |
|
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | |
@@ -254,13 +254,13 @@ discard block |
||
| 254 | 254 | public function createTable ( $nameTable, $schema = 0 ) |
| 255 | 255 | { |
| 256 | 256 | $this->objDbTables[ $schema ][ trim ( $nameTable ) ] = DbTable::getInstance () |
| 257 | - ->populate ( |
|
| 258 | - array ( |
|
| 259 | - 'table' => $nameTable, |
|
| 260 | - 'schema' => $schema, |
|
| 261 | - 'database' => $this->database |
|
| 262 | - ) |
|
| 263 | - ); |
|
| 257 | + ->populate ( |
|
| 258 | + array ( |
|
| 259 | + 'table' => $nameTable, |
|
| 260 | + 'schema' => $schema, |
|
| 261 | + 'database' => $this->database |
|
| 262 | + ) |
|
| 263 | + ); |
|
| 264 | 264 | |
| 265 | 265 | return $this; |
| 266 | 266 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | /** |
| 60 | 60 | * @type \Classes\Db\DbTable[][] |
| 61 | 61 | */ |
| 62 | - private $objDbTables = array (); |
|
| 62 | + private $objDbTables = array(); |
|
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * @var AbstractAdapter |
@@ -74,20 +74,20 @@ discard block |
||
| 74 | 74 | /** |
| 75 | 75 | * analisa e popula as Foreing keys, Primary keys e dependencias do banco nos objetos |
| 76 | 76 | */ |
| 77 | - protected function parseConstrants () |
|
| 77 | + protected function parseConstrants() |
|
| 78 | 78 | { |
| 79 | - foreach ( $this->getListConstrant () as $constrant ) { |
|
| 80 | - |
|
| 81 | - $schema = $constrant[ 'table_schema' ]; |
|
| 82 | - $table_name = $constrant [ 'table_name' ]; |
|
| 83 | - $this->populateForeignAndPrimaryKeys ( $constrant, $table_name, $schema ); |
|
| 84 | - unset( $table_name, $schema ); |
|
| 85 | - |
|
| 86 | - if ( $constrant[ 'constraint_type' ] == "FOREIGN KEY" ) { |
|
| 87 | - $schema = $constrant[ 'foreign_schema' ]; |
|
| 88 | - $table_name = $constrant [ 'foreign_table' ]; |
|
| 89 | - $this->populateDependece ( $constrant, $table_name, $schema ); |
|
| 90 | - unset( $table_name, $schema ); |
|
| 79 | + foreach ($this->getListConstrant() as $constrant) { |
|
| 80 | + |
|
| 81 | + $schema = $constrant['table_schema']; |
|
| 82 | + $table_name = $constrant ['table_name']; |
|
| 83 | + $this->populateForeignAndPrimaryKeys($constrant, $table_name, $schema); |
|
| 84 | + unset($table_name, $schema); |
|
| 85 | + |
|
| 86 | + if ($constrant['constraint_type'] == "FOREIGN KEY") { |
|
| 87 | + $schema = $constrant['foreign_schema']; |
|
| 88 | + $table_name = $constrant ['foreign_table']; |
|
| 89 | + $this->populateDependece($constrant, $table_name, $schema); |
|
| 90 | + unset($table_name, $schema); |
|
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -97,34 +97,34 @@ discard block |
||
| 97 | 97 | * @param string $table_name |
| 98 | 98 | * @param int $schema |
| 99 | 99 | */ |
| 100 | - private function populateForeignAndPrimaryKeys ( $constrant, $table_name, $schema = 0 ) |
|
| 100 | + private function populateForeignAndPrimaryKeys($constrant, $table_name, $schema = 0) |
|
| 101 | 101 | { |
| 102 | - if ( $this->hasTable ( $table_name, $schema ) ) { |
|
| 103 | - $table = $this->getTable ( $table_name, $schema ); |
|
| 104 | - if ( $table->hasColumn ( $constrant[ "column_name" ] ) ) { |
|
| 105 | - $objConstrant = Constrant::getInstance () |
|
| 106 | - ->populate ( |
|
| 107 | - array ( |
|
| 108 | - 'constrant' => $constrant[ 'constraint_name' ], |
|
| 109 | - 'schema' => $constrant[ 'foreign_schema' ], |
|
| 110 | - 'table' => $constrant[ 'foreign_table' ], |
|
| 111 | - 'column' => $constrant[ 'foreign_column' ], |
|
| 102 | + if ($this->hasTable($table_name, $schema)) { |
|
| 103 | + $table = $this->getTable($table_name, $schema); |
|
| 104 | + if ($table->hasColumn($constrant["column_name"])) { |
|
| 105 | + $objConstrant = Constrant::getInstance() |
|
| 106 | + ->populate( |
|
| 107 | + array( |
|
| 108 | + 'constrant' => $constrant['constraint_name'], |
|
| 109 | + 'schema' => $constrant['foreign_schema'], |
|
| 110 | + 'table' => $constrant['foreign_table'], |
|
| 111 | + 'column' => $constrant['foreign_column'], |
|
| 112 | 112 | 'database' => $this->database |
| 113 | 113 | ) |
| 114 | 114 | ); |
| 115 | 115 | |
| 116 | - switch ( $constrant[ 'constraint_type' ] ) { |
|
| 116 | + switch ($constrant['constraint_type']) { |
|
| 117 | 117 | case "FOREIGN KEY": |
| 118 | - $table->getColumn ( $constrant[ "column_name" ] ) |
|
| 119 | - ->addRefFk ( $objConstrant ); |
|
| 118 | + $table->getColumn($constrant["column_name"]) |
|
| 119 | + ->addRefFk($objConstrant); |
|
| 120 | 120 | break; |
| 121 | 121 | case"PRIMARY KEY": |
| 122 | - $table->getColumn ( $constrant[ "column_name" ] ) |
|
| 123 | - ->setPrimaryKey ( $objConstrant ) |
|
| 124 | - ->setSequence ( |
|
| 125 | - $this->getSequence ( |
|
| 122 | + $table->getColumn($constrant["column_name"]) |
|
| 123 | + ->setPrimaryKey($objConstrant) |
|
| 124 | + ->setSequence( |
|
| 125 | + $this->getSequence( |
|
| 126 | 126 | $table_name, |
| 127 | - $constrant[ "column_name" ], |
|
| 127 | + $constrant["column_name"], |
|
| 128 | 128 | $schema |
| 129 | 129 | ) |
| 130 | 130 | ); |
@@ -139,18 +139,18 @@ discard block |
||
| 139 | 139 | * @param string $table_name |
| 140 | 140 | * @param int $schema |
| 141 | 141 | */ |
| 142 | - private function populateDependece ( $constrant, $table_name, $schema = 0 ) |
|
| 142 | + private function populateDependece($constrant, $table_name, $schema = 0) |
|
| 143 | 143 | { |
| 144 | - if ( $this->hasTable ( $table_name, $schema ) ) { |
|
| 145 | - $table = $this->getTable ( $table_name, $schema ); |
|
| 146 | - if ( $table->hasColumn ( $constrant[ "foreign_column" ] ) ) { |
|
| 147 | - $table->getColumn ( $constrant[ "foreign_column" ] ) |
|
| 148 | - ->createDependece ( |
|
| 149 | - $constrant[ 'constraint_name' ], |
|
| 150 | - $constrant[ 'table_name' ], |
|
| 151 | - $constrant[ 'column_name' ], |
|
| 144 | + if ($this->hasTable($table_name, $schema)) { |
|
| 145 | + $table = $this->getTable($table_name, $schema); |
|
| 146 | + if ($table->hasColumn($constrant["foreign_column"])) { |
|
| 147 | + $table->getColumn($constrant["foreign_column"]) |
|
| 148 | + ->createDependece( |
|
| 149 | + $constrant['constraint_name'], |
|
| 150 | + $constrant['table_name'], |
|
| 151 | + $constrant['column_name'], |
|
| 152 | 152 | $this->database, |
| 153 | - $constrant[ 'table_schema' ] |
|
| 153 | + $constrant['table_schema'] |
|
| 154 | 154 | ); |
| 155 | 155 | } |
| 156 | 156 | } |
@@ -159,33 +159,33 @@ discard block |
||
| 159 | 159 | /** |
| 160 | 160 | * cria um Array com nome das tabelas |
| 161 | 161 | */ |
| 162 | - public function parseTables () |
|
| 162 | + public function parseTables() |
|
| 163 | 163 | { |
| 164 | - if ( $this->hasTables () ) { |
|
| 165 | - return $this->getAllTables (); |
|
| 164 | + if ($this->hasTables()) { |
|
| 165 | + return $this->getAllTables(); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - foreach ( $this->getListColumns () as $table ) { |
|
| 169 | - $schema = $table[ 'table_schema' ]; |
|
| 170 | - $key = $table [ 'table_name' ]; |
|
| 171 | - if ( !$this->hasTable ( $key, $schema ) ) { |
|
| 172 | - $this->createTable ( $key, $schema ); |
|
| 168 | + foreach ($this->getListColumns() as $table) { |
|
| 169 | + $schema = $table['table_schema']; |
|
| 170 | + $key = $table ['table_name']; |
|
| 171 | + if ( ! $this->hasTable($key, $schema)) { |
|
| 172 | + $this->createTable($key, $schema); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - $column = Column::getInstance () |
|
| 176 | - ->populate ( |
|
| 177 | - array ( |
|
| 178 | - 'name' => $table [ 'column_name' ], |
|
| 179 | - 'type' => $this->convertTypeToSimple ( $table[ 'data_type' ] ), |
|
| 180 | - 'nullable' => ( $table[ 'is_nullable' ] == 'YES' ), |
|
| 181 | - 'max_length' => $table[ 'max_length' ] |
|
| 175 | + $column = Column::getInstance() |
|
| 176 | + ->populate( |
|
| 177 | + array( |
|
| 178 | + 'name' => $table ['column_name'], |
|
| 179 | + 'type' => $this->convertTypeToSimple($table['data_type']), |
|
| 180 | + 'nullable' => ($table['is_nullable'] == 'YES'), |
|
| 181 | + 'max_length' => $table['max_length'] |
|
| 182 | 182 | ) |
| 183 | 183 | ); |
| 184 | 184 | |
| 185 | - $this->getTable ( $key, $schema ) |
|
| 186 | - ->addColumn ( $column ) |
|
| 187 | - ->setNamespace ( |
|
| 188 | - $this->config->createClassNamespace ( $this->getTable ( $key, $schema ) ) |
|
| 185 | + $this->getTable($key, $schema) |
|
| 186 | + ->addColumn($column) |
|
| 187 | + ->setNamespace( |
|
| 188 | + $this->config->createClassNamespace($this->getTable($key, $schema)) |
|
| 189 | 189 | ); |
| 190 | 190 | } |
| 191 | 191 | } |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * |
| 196 | 196 | * @return int |
| 197 | 197 | */ |
| 198 | - abstract public function getTotalTables (); |
|
| 198 | + abstract public function getTotalTables(); |
|
| 199 | 199 | |
| 200 | 200 | /** |
| 201 | 201 | * Retorna o Nome da Sequence da tabela |
@@ -205,31 +205,31 @@ discard block |
||
| 205 | 205 | * |
| 206 | 206 | * @return string |
| 207 | 207 | */ |
| 208 | - abstract public function getSequence ( $table, $column, $schema = 0 ); |
|
| 208 | + abstract public function getSequence($table, $column, $schema = 0); |
|
| 209 | 209 | |
| 210 | 210 | /** |
| 211 | 211 | * @return array |
| 212 | 212 | */ |
| 213 | - abstract public function getListConstrant (); |
|
| 213 | + abstract public function getListConstrant(); |
|
| 214 | 214 | |
| 215 | 215 | /** |
| 216 | 216 | * @param string $str |
| 217 | 217 | * |
| 218 | 218 | * @return string |
| 219 | 219 | */ |
| 220 | - protected function convertTypeToPhp ( $str ) |
|
| 220 | + protected function convertTypeToPhp($str) |
|
| 221 | 221 | { |
| 222 | - if ( isset( $this->dataTypesToPhp[ $str ] ) ) { |
|
| 223 | - return $this->dataTypesToPhp[ $str ]; |
|
| 222 | + if (isset($this->dataTypesToPhp[$str])) { |
|
| 223 | + return $this->dataTypesToPhp[$str]; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | return 'string'; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - protected function convertTypeToSimple ( $str ) |
|
| 229 | + protected function convertTypeToSimple($str) |
|
| 230 | 230 | { |
| 231 | - if ( isset( $this->dataTypesToSimple[ $str ] ) ) { |
|
| 232 | - return $this->dataTypesToSimple[ $str ]; |
|
| 231 | + if (isset($this->dataTypesToSimple[$str])) { |
|
| 232 | + return $this->dataTypesToSimple[$str]; |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | return 'string'; |
@@ -238,12 +238,12 @@ discard block |
||
| 238 | 238 | /** |
| 239 | 239 | * @return string |
| 240 | 240 | */ |
| 241 | - abstract public function getPDOString (); |
|
| 241 | + abstract public function getPDOString(); |
|
| 242 | 242 | |
| 243 | 243 | /** |
| 244 | 244 | * @return string |
| 245 | 245 | */ |
| 246 | - abstract public function getPDOSocketString (); |
|
| 246 | + abstract public function getPDOSocketString(); |
|
| 247 | 247 | |
| 248 | 248 | /** |
| 249 | 249 | * @param $nameTable |
@@ -251,11 +251,11 @@ discard block |
||
| 251 | 251 | * |
| 252 | 252 | * @return \Classes\Db\DbTable |
| 253 | 253 | */ |
| 254 | - public function createTable ( $nameTable, $schema = 0 ) |
|
| 254 | + public function createTable($nameTable, $schema = 0) |
|
| 255 | 255 | { |
| 256 | - $this->objDbTables[ $schema ][ trim ( $nameTable ) ] = DbTable::getInstance () |
|
| 257 | - ->populate ( |
|
| 258 | - array ( |
|
| 256 | + $this->objDbTables[$schema][trim($nameTable)] = DbTable::getInstance() |
|
| 257 | + ->populate( |
|
| 258 | + array( |
|
| 259 | 259 | 'table' => $nameTable, |
| 260 | 260 | 'schema' => $schema, |
| 261 | 261 | 'database' => $this->database |
@@ -270,23 +270,23 @@ discard block |
||
| 270 | 270 | * |
| 271 | 271 | * @return \Classes\Db\DbTable[] |
| 272 | 272 | */ |
| 273 | - public function getTables ( $schema = 0 ) |
|
| 273 | + public function getTables($schema = 0) |
|
| 274 | 274 | { |
| 275 | - if ( !isset( $this->objDbTables[ $schema ] ) ) { |
|
| 276 | - return array (); |
|
| 275 | + if ( ! isset($this->objDbTables[$schema])) { |
|
| 276 | + return array(); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - return $this->objDbTables[ $schema ]; |
|
| 279 | + return $this->objDbTables[$schema]; |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - public function getAllTables () |
|
| 282 | + public function getAllTables() |
|
| 283 | 283 | { |
| 284 | 284 | return $this->objDbTables; |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - public function hasTables () |
|
| 287 | + public function hasTables() |
|
| 288 | 288 | { |
| 289 | - return !empty( $this->objDbTables ); |
|
| 289 | + return ! empty($this->objDbTables); |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | /** |
@@ -296,9 +296,9 @@ discard block |
||
| 296 | 296 | * |
| 297 | 297 | * @return \Classes\Db\DbTable |
| 298 | 298 | */ |
| 299 | - public function getTable ( $nameTable, $schema = 0 ) |
|
| 299 | + public function getTable($nameTable, $schema = 0) |
|
| 300 | 300 | { |
| 301 | - return $this->objDbTables[ $schema ][ trim ( $nameTable ) ]; |
|
| 301 | + return $this->objDbTables[$schema][trim($nameTable)]; |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
@@ -307,9 +307,9 @@ discard block |
||
| 307 | 307 | * |
| 308 | 308 | * @return bool |
| 309 | 309 | */ |
| 310 | - public function hasTable ( $nameTable, $schema = 0 ) |
|
| 310 | + public function hasTable($nameTable, $schema = 0) |
|
| 311 | 311 | { |
| 312 | - return isset( $this->objDbTables[ $schema ][ trim ( $nameTable ) ] ); |
|
| 312 | + return isset($this->objDbTables[$schema][trim($nameTable)]); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | /** |
@@ -317,59 +317,59 @@ discard block |
||
| 317 | 317 | * |
| 318 | 318 | * @return array[] |
| 319 | 319 | */ |
| 320 | - abstract public function getListColumns (); |
|
| 320 | + abstract public function getListColumns(); |
|
| 321 | 321 | |
| 322 | 322 | /** |
| 323 | 323 | * Retorna um Array com nome das tabelas |
| 324 | 324 | * |
| 325 | 325 | * @return string[] |
| 326 | 326 | */ |
| 327 | - abstract public function getListNameTable (); |
|
| 327 | + abstract public function getListNameTable(); |
|
| 328 | 328 | |
| 329 | 329 | /** |
| 330 | 330 | * @param \Classes\AdapterConfig\AbstractAdapter $adapterConfig |
| 331 | 331 | */ |
| 332 | - public function __construct ( AbstractAdapter $adapterConfig ) |
|
| 332 | + public function __construct(AbstractAdapter $adapterConfig) |
|
| 333 | 333 | { |
| 334 | 334 | $this->config = $adapterConfig; |
| 335 | - $this->host = $adapterConfig->getHost (); |
|
| 336 | - $this->database = $adapterConfig->getDatabase (); |
|
| 337 | - $this->port = $adapterConfig->hasPort () ? $adapterConfig->getPort () : $this->port; |
|
| 338 | - $this->username = $adapterConfig->getUser (); |
|
| 339 | - $this->password = $adapterConfig->getPassword (); |
|
| 340 | - $this->socket = $adapterConfig->getSocket (); |
|
| 335 | + $this->host = $adapterConfig->getHost(); |
|
| 336 | + $this->database = $adapterConfig->getDatabase(); |
|
| 337 | + $this->port = $adapterConfig->hasPort() ? $adapterConfig->getPort() : $this->port; |
|
| 338 | + $this->username = $adapterConfig->getUser(); |
|
| 339 | + $this->password = $adapterConfig->getPassword(); |
|
| 340 | + $this->socket = $adapterConfig->getSocket(); |
|
| 341 | 341 | |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | /** |
| 345 | 345 | * Executa as consultas do banco de dados |
| 346 | 346 | */ |
| 347 | - public function runDatabase () |
|
| 347 | + public function runDatabase() |
|
| 348 | 348 | { |
| 349 | - $this->parseTables (); |
|
| 350 | - $this->parseConstrants (); |
|
| 349 | + $this->parseTables(); |
|
| 350 | + $this->parseConstrants(); |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | /** |
| 354 | 354 | * |
| 355 | 355 | * @return \PDO |
| 356 | 356 | */ |
| 357 | - public function getPDO () |
|
| 357 | + public function getPDO() |
|
| 358 | 358 | { |
| 359 | - if ( is_null ( $this->_pdo ) ) { |
|
| 360 | - if ( !empty( $this->socket ) ) { |
|
| 361 | - $pdoString = $this->getPDOSocketString (); |
|
| 359 | + if (is_null($this->_pdo)) { |
|
| 360 | + if ( ! empty($this->socket)) { |
|
| 361 | + $pdoString = $this->getPDOSocketString(); |
|
| 362 | 362 | } |
| 363 | 363 | else { |
| 364 | - $pdoString = $this->getPDOString (); |
|
| 364 | + $pdoString = $this->getPDOString(); |
|
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | try { |
| 368 | - $this->_pdo = new \PDO ( |
|
| 368 | + $this->_pdo = new \PDO( |
|
| 369 | 369 | $pdoString, $this->username, $this->password |
| 370 | 370 | ); |
| 371 | - } catch ( \Exception $e ) { |
|
| 372 | - die ( "pdo error: " . $e->getMessage () . "\n" ); |
|
| 371 | + } catch (\Exception $e) { |
|
| 372 | + die ("pdo error: " . $e->getMessage() . "\n"); |
|
| 373 | 373 | } |
| 374 | 374 | } |
| 375 | 375 | |
@@ -359,8 +359,7 @@ |
||
| 359 | 359 | if ( is_null ( $this->_pdo ) ) { |
| 360 | 360 | if ( !empty( $this->socket ) ) { |
| 361 | 361 | $pdoString = $this->getPDOSocketString (); |
| 362 | - } |
|
| 363 | - else { |
|
| 362 | + } else { |
|
| 364 | 363 | $pdoString = $this->getPDOString (); |
| 365 | 364 | } |
| 366 | 365 | |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | /** |
| 151 | 151 | * @param AbstractAdapter $type |
| 152 | 152 | * |
| 153 | - * @return mixed |
|
| 153 | + * @return string |
|
| 154 | 154 | */ |
| 155 | 155 | public function getTypeByConfig ( AbstractAdapter $type ) |
| 156 | 156 | { |
@@ -199,6 +199,7 @@ discard block |
||
| 199 | 199 | * @param $constraint_name |
| 200 | 200 | * @param $table_name |
| 201 | 201 | * @param $column_name |
| 202 | + * @param string $database |
|
| 202 | 203 | * |
| 203 | 204 | * @return $this |
| 204 | 205 | */ |
@@ -205,15 +205,15 @@ |
||
| 205 | 205 | public function createDependece ( $constraint_name, $table_name, $column_name, $database, $schema = null ) |
| 206 | 206 | { |
| 207 | 207 | $objConstrantDependence = Constrant::getInstance () |
| 208 | - ->populate ( |
|
| 209 | - array ( |
|
| 210 | - 'constrant' => $constraint_name, |
|
| 211 | - 'schema' => $schema, |
|
| 212 | - 'table' => $table_name, |
|
| 213 | - 'column' => $column_name, |
|
| 214 | - 'database' => $database |
|
| 215 | - ) |
|
| 216 | - ); |
|
| 208 | + ->populate ( |
|
| 209 | + array ( |
|
| 210 | + 'constrant' => $constraint_name, |
|
| 211 | + 'schema' => $schema, |
|
| 212 | + 'table' => $table_name, |
|
| 213 | + 'column' => $column_name, |
|
| 214 | + 'database' => $database |
|
| 215 | + ) |
|
| 216 | + ); |
|
| 217 | 217 | |
| 218 | 218 | $this->addDependece ( $objConstrantDependence ); |
| 219 | 219 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @author Pedro Alarcao <[email protected]> |
| 20 | 20 | */ |
| 21 | - final private function __construct () |
|
| 21 | + final private function __construct() |
|
| 22 | 22 | { |
| 23 | 23 | } |
| 24 | 24 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @return \Classes\Db\Column |
| 29 | 29 | */ |
| 30 | - public static function getInstance () |
|
| 30 | + public static function getInstance() |
|
| 31 | 31 | { |
| 32 | 32 | return new Column(); |
| 33 | 33 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | /** |
| 81 | 81 | * @return string |
| 82 | 82 | */ |
| 83 | - public function getName () |
|
| 83 | + public function getName() |
|
| 84 | 84 | { |
| 85 | 85 | return $this->name; |
| 86 | 86 | } |
@@ -90,12 +90,12 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @param $array |
| 92 | 92 | */ |
| 93 | - public function populate ( $array ) |
|
| 93 | + public function populate($array) |
|
| 94 | 94 | { |
| 95 | - $this->name = $array[ 'name' ]; |
|
| 96 | - $this->type = $array[ 'type' ]; |
|
| 97 | - $this->nullable = $array[ 'nullable' ]; |
|
| 98 | - $this->max_length = $array[ 'max_length' ]; |
|
| 95 | + $this->name = $array['name']; |
|
| 96 | + $this->type = $array['type']; |
|
| 97 | + $this->nullable = $array['nullable']; |
|
| 98 | + $this->max_length = $array['max_length']; |
|
| 99 | 99 | |
| 100 | 100 | return $this; |
| 101 | 101 | } |
@@ -103,37 +103,37 @@ discard block |
||
| 103 | 103 | /** |
| 104 | 104 | * @return boolean |
| 105 | 105 | */ |
| 106 | - public function isPrimaryKey () |
|
| 106 | + public function isPrimaryKey() |
|
| 107 | 107 | { |
| 108 | - return !empty( $this->primarykey ); |
|
| 108 | + return ! empty($this->primarykey); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
| 112 | 112 | * @return boolean |
| 113 | 113 | */ |
| 114 | - public function isForeingkey () |
|
| 114 | + public function isForeingkey() |
|
| 115 | 115 | { |
| 116 | - return !empty( $this->refForeingkey ); |
|
| 116 | + return ! empty($this->refForeingkey); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | 120 | * @return boolean |
| 121 | 121 | */ |
| 122 | - public function hasDependence () |
|
| 122 | + public function hasDependence() |
|
| 123 | 123 | { |
| 124 | - return !empty( $this->dependences ); |
|
| 124 | + return ! empty($this->dependences); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
| 128 | 128 | * @return string |
| 129 | 129 | */ |
| 130 | - public function getType ( $inPHP = true ) |
|
| 130 | + public function getType($inPHP = true) |
|
| 131 | 131 | { |
| 132 | - if ( !$inPHP ) { |
|
| 132 | + if ( ! $inPHP) { |
|
| 133 | 133 | return $this->type; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - return AbstractAdapter::convertTypeToPHP ( $this->type ); |
|
| 136 | + return AbstractAdapter::convertTypeToPHP($this->type); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -142,9 +142,9 @@ discard block |
||
| 142 | 142 | * |
| 143 | 143 | * @return bool |
| 144 | 144 | */ |
| 145 | - public function equalType ( $type, $inPHP = true ) |
|
| 145 | + public function equalType($type, $inPHP = true) |
|
| 146 | 146 | { |
| 147 | - return $this->getType ( $inPHP ) === $type; |
|
| 147 | + return $this->getType($inPHP) === $type; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -152,15 +152,15 @@ discard block |
||
| 152 | 152 | * |
| 153 | 153 | * @return mixed |
| 154 | 154 | */ |
| 155 | - public function getTypeByConfig ( AbstractAdapter $type ) |
|
| 155 | + public function getTypeByConfig(AbstractAdapter $type) |
|
| 156 | 156 | { |
| 157 | - return $type->convertTypeToTypeFramework ( $this->getType ( false ) ); |
|
| 157 | + return $type->convertTypeToTypeFramework($this->getType(false)); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /** |
| 161 | 161 | * @return string |
| 162 | 162 | */ |
| 163 | - public function getComment () |
|
| 163 | + public function getComment() |
|
| 164 | 164 | { |
| 165 | 165 | return $this->comment; |
| 166 | 166 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | /** |
| 169 | 169 | * @param string $comment |
| 170 | 170 | */ |
| 171 | - public function setComment ( $comment ) |
|
| 171 | + public function setComment($comment) |
|
| 172 | 172 | { |
| 173 | 173 | $this->comment = $comment; |
| 174 | 174 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | /** |
| 179 | 179 | * @param \Classes\Db\Constrant $primarykey |
| 180 | 180 | */ |
| 181 | - public function setPrimaryKey ( Constrant $primarykey ) |
|
| 181 | + public function setPrimaryKey(Constrant $primarykey) |
|
| 182 | 182 | { |
| 183 | 183 | $this->primarykey = $primarykey; |
| 184 | 184 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | /** |
| 189 | 189 | * @param \Classes\Db\Constrant $dependece |
| 190 | 190 | */ |
| 191 | - public function addDependece ( Constrant $dependece ) |
|
| 191 | + public function addDependece(Constrant $dependece) |
|
| 192 | 192 | { |
| 193 | 193 | $this->dependences[] = $dependece; |
| 194 | 194 | |
@@ -202,11 +202,11 @@ discard block |
||
| 202 | 202 | * |
| 203 | 203 | * @return $this |
| 204 | 204 | */ |
| 205 | - public function createDependece ( $constraint_name, $table_name, $column_name, $database, $schema = null ) |
|
| 205 | + public function createDependece($constraint_name, $table_name, $column_name, $database, $schema = null) |
|
| 206 | 206 | { |
| 207 | - $objConstrantDependence = Constrant::getInstance () |
|
| 208 | - ->populate ( |
|
| 209 | - array ( |
|
| 207 | + $objConstrantDependence = Constrant::getInstance() |
|
| 208 | + ->populate( |
|
| 209 | + array( |
|
| 210 | 210 | 'constrant' => $constraint_name, |
| 211 | 211 | 'schema' => $schema, |
| 212 | 212 | 'table' => $table_name, |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | ) |
| 216 | 216 | ); |
| 217 | 217 | |
| 218 | - $this->addDependece ( $objConstrantDependence ); |
|
| 218 | + $this->addDependece($objConstrantDependence); |
|
| 219 | 219 | |
| 220 | 220 | return $this; |
| 221 | 221 | } |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | /** |
| 224 | 224 | * @param \Classes\Db\Constrant $reference |
| 225 | 225 | */ |
| 226 | - public function addRefFk ( Constrant $reference ) |
|
| 226 | + public function addRefFk(Constrant $reference) |
|
| 227 | 227 | { |
| 228 | 228 | $this->refForeingkey = $reference; |
| 229 | 229 | |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | * |
| 236 | 236 | * @return \Classes\Db\Constrant |
| 237 | 237 | */ |
| 238 | - public function getFks () |
|
| 238 | + public function getFks() |
|
| 239 | 239 | { |
| 240 | 240 | return $this->refForeingkey; |
| 241 | 241 | } |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | * |
| 246 | 246 | * @return \Classes\Db\Constrant[] |
| 247 | 247 | */ |
| 248 | - public function getDependences () |
|
| 248 | + public function getDependences() |
|
| 249 | 249 | { |
| 250 | 250 | return $this->dependences; |
| 251 | 251 | } |
@@ -253,9 +253,9 @@ discard block |
||
| 253 | 253 | /** |
| 254 | 254 | * @return bool |
| 255 | 255 | */ |
| 256 | - public function hasDependences () |
|
| 256 | + public function hasDependences() |
|
| 257 | 257 | { |
| 258 | - return (bool) count ( $this->dependences ); |
|
| 258 | + return (bool) count($this->dependences); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | /** |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | * |
| 264 | 264 | * @return \Classes\Db\Constrant[] |
| 265 | 265 | */ |
| 266 | - public function getPrimaryKey () |
|
| 266 | + public function getPrimaryKey() |
|
| 267 | 267 | { |
| 268 | 268 | return $this->primarykey; |
| 269 | 269 | } |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | /** |
| 272 | 272 | * |
| 273 | 273 | */ |
| 274 | - public function getMaxLength () |
|
| 274 | + public function getMaxLength() |
|
| 275 | 275 | { |
| 276 | 276 | return $this->max_length; |
| 277 | 277 | } |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | /** |
| 280 | 280 | * @return bool |
| 281 | 281 | */ |
| 282 | - public function hasSequence () |
|
| 282 | + public function hasSequence() |
|
| 283 | 283 | { |
| 284 | 284 | return (bool) $this->sequence; |
| 285 | 285 | } |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | /** |
| 288 | 288 | * @return string |
| 289 | 289 | */ |
| 290 | - public function getSequence () |
|
| 290 | + public function getSequence() |
|
| 291 | 291 | { |
| 292 | 292 | return $this->sequence; |
| 293 | 293 | } |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | /** |
| 296 | 296 | * @param string $sequence |
| 297 | 297 | */ |
| 298 | - public function setSequence ( $sequence ) |
|
| 298 | + public function setSequence($sequence) |
|
| 299 | 299 | { |
| 300 | 300 | $this->sequence = $sequence; |
| 301 | 301 | } |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | /** |
| 304 | 304 | * @return boolean |
| 305 | 305 | */ |
| 306 | - public function isNullable () |
|
| 306 | + public function isNullable() |
|
| 307 | 307 | { |
| 308 | 308 | return $this->nullable; |
| 309 | 309 | } |
@@ -96,6 +96,7 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | 98 | * Analisa os caminhos das pastas base |
| 99 | + * @param string $basePath |
|
| 99 | 100 | */ |
| 100 | 101 | public function parseLocation ( $basePath ) |
| 101 | 102 | { |
@@ -269,6 +270,7 @@ discard block |
||
| 269 | 270 | * parse a tpl file and return the result |
| 270 | 271 | * |
| 271 | 272 | * @param String $tplFile |
| 273 | + * @param AbstractAdapter $objMakeFile |
|
| 272 | 274 | * |
| 273 | 275 | * @return String |
| 274 | 276 | */ |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | { |
| 89 | 89 | foreach ( $arrFoldersName as $index => $folderName ) { |
| 90 | 90 | $arrFoldersName[ $index ] = $this->getConfig () |
| 91 | - ->replaceReservedWord ( $folderName ); |
|
| 91 | + ->replaceReservedWord ( $folderName ); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | return implode ( DIRECTORY_SEPARATOR, array_filter ( $arrFoldersName ) ); |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | $folderName, |
| 142 | 142 | $this->getClassName ( |
| 143 | 143 | $this->getConfig () |
| 144 | - ->getDatabase () |
|
| 144 | + ->getDatabase () |
|
| 145 | 145 | ) |
| 146 | 146 | ); |
| 147 | 147 | $this->location = array ( $this->filterLocation ( $url ) ); |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | * @return String |
| 274 | 274 | */ |
| 275 | 275 | protected function getParsedTplContents ( $tplFile, $vars = array (), \Classes\Db\DbTable $objTables = null, |
| 276 | - $objMakeFile = null ) |
|
| 276 | + $objMakeFile = null ) |
|
| 277 | 277 | { |
| 278 | 278 | |
| 279 | 279 | $arrUrl = array ( |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | /** |
| 19 | 19 | * @type string[] |
| 20 | 20 | */ |
| 21 | - public $location = array (); |
|
| 21 | + public $location = array(); |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * caminho de pastas Base |
@@ -39,42 +39,42 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | private $msgReservedWord = "\033[0mPlease enter the value for reserved word \033[0;31m'%index%' \033[1;33m[%config%]:\033[0m "; |
| 41 | 41 | |
| 42 | - public function __construct ( Config $config ) |
|
| 42 | + public function __construct(Config $config) |
|
| 43 | 43 | { |
| 44 | - $this->config = $config->getAdapterConfig (); |
|
| 45 | - $this->parseReservedWord ( $this->getConfig () ); |
|
| 46 | - $this->driver = $config->getAdapterDriver ( $this->getConfig () ); |
|
| 47 | - $this->parseLocation ( $config->_basePath ); |
|
| 44 | + $this->config = $config->getAdapterConfig(); |
|
| 45 | + $this->parseReservedWord($this->getConfig()); |
|
| 46 | + $this->driver = $config->getAdapterDriver($this->getConfig()); |
|
| 47 | + $this->parseLocation($config->_basePath); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * @param AdapterConfig\AbstractAdapter $config |
| 52 | 52 | */ |
| 53 | - public function parseReservedWord ( AdapterConfig\AbstractAdapter $config ) |
|
| 53 | + public function parseReservedWord(AdapterConfig\AbstractAdapter $config) |
|
| 54 | 54 | { |
| 55 | 55 | $palavrasReservadas = $config->reservedWord; |
| 56 | - if ( !$palavrasReservadas ) { |
|
| 56 | + if ( ! $palavrasReservadas) { |
|
| 57 | 57 | return; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $schema = $config->getSchemas (); |
|
| 61 | - $db = $config->getDatabase (); |
|
| 62 | - $hasSchema = array_intersect ( $schema, array_flip ( $palavrasReservadas ) ); |
|
| 63 | - $hasDatabase = in_array ( $db, $palavrasReservadas ); |
|
| 64 | - if ( !( $hasSchema or $hasDatabase ) ) { |
|
| 60 | + $schema = $config->getSchemas(); |
|
| 61 | + $db = $config->getDatabase(); |
|
| 62 | + $hasSchema = array_intersect($schema, array_flip($palavrasReservadas)); |
|
| 63 | + $hasDatabase = in_array($db, $palavrasReservadas); |
|
| 64 | + if ( ! ($hasSchema or $hasDatabase)) { |
|
| 65 | 65 | return; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | echo "- database has reserved words\n"; |
| 69 | - foreach ( $palavrasReservadas as $index => $config ) { |
|
| 70 | - $attribs = array ( |
|
| 69 | + foreach ($palavrasReservadas as $index => $config) { |
|
| 70 | + $attribs = array( |
|
| 71 | 71 | "%index%" => $index, |
| 72 | 72 | "%config%" => $config |
| 73 | 73 | ); |
| 74 | - echo strtr ( $this->msgReservedWord, $attribs ); |
|
| 75 | - $line = trim ( fgets ( STDIN ) ); |
|
| 76 | - if ( !empty( $line ) ) { |
|
| 77 | - $this->getConfig ()->reservedWord[ $index ] = $line; |
|
| 74 | + echo strtr($this->msgReservedWord, $attribs); |
|
| 75 | + $line = trim(fgets(STDIN)); |
|
| 76 | + if ( ! empty($line)) { |
|
| 77 | + $this->getConfig()->reservedWord[$index] = $line; |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -84,155 +84,155 @@ discard block |
||
| 84 | 84 | * |
| 85 | 85 | * @return string |
| 86 | 86 | */ |
| 87 | - private function filterLocation ( $arrFoldersName ) |
|
| 87 | + private function filterLocation($arrFoldersName) |
|
| 88 | 88 | { |
| 89 | - foreach ( $arrFoldersName as $index => $folderName ) { |
|
| 90 | - $arrFoldersName[ $index ] = $this->getConfig () |
|
| 91 | - ->replaceReservedWord ( $folderName ); |
|
| 89 | + foreach ($arrFoldersName as $index => $folderName) { |
|
| 90 | + $arrFoldersName[$index] = $this->getConfig() |
|
| 91 | + ->replaceReservedWord($folderName); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - return implode ( DIRECTORY_SEPARATOR, array_filter ( $arrFoldersName ) ); |
|
| 94 | + return implode(DIRECTORY_SEPARATOR, array_filter($arrFoldersName)); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | 98 | * Analisa os caminhos das pastas base |
| 99 | 99 | */ |
| 100 | - public function parseLocation ( $basePath ) |
|
| 100 | + public function parseLocation($basePath) |
|
| 101 | 101 | { |
| 102 | 102 | |
| 103 | - $arrBase = array ( |
|
| 103 | + $arrBase = array( |
|
| 104 | 104 | $basePath, |
| 105 | 105 | $this->config->path |
| 106 | 106 | ); |
| 107 | 107 | |
| 108 | - $this->baseLocation = $this->filterLocation ( $arrBase ); |
|
| 108 | + $this->baseLocation = $this->filterLocation($arrBase); |
|
| 109 | 109 | |
| 110 | 110 | # pasta com nome do driver do banco |
| 111 | 111 | $driverBase = ''; |
| 112 | - if ( (bool) @$this->config->{"folder-database"} ) { |
|
| 113 | - $classDriver = explode ( '\\', get_class ( $this->driver ) ); |
|
| 114 | - $driverBase = end ( $classDriver ); |
|
| 112 | + if ((bool) @$this->config->{"folder-database"} ) { |
|
| 113 | + $classDriver = explode('\\', get_class($this->driver)); |
|
| 114 | + $driverBase = end($classDriver); |
|
| 115 | 115 | } |
| 116 | 116 | $folderName = ''; |
| 117 | - if ( (bool) @$this->config->{"folder-name"} ) { |
|
| 118 | - $folderName = $this->getClassName ( trim ( $this->config->{"folder-name"} ) ); |
|
| 117 | + if ((bool) @$this->config->{"folder-name"} ) { |
|
| 118 | + $folderName = $this->getClassName(trim($this->config->{"folder-name"} )); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - if ( $this->config->hasSchemas () ) { |
|
| 121 | + if ($this->config->hasSchemas()) { |
|
| 122 | 122 | |
| 123 | - $schemas = $this->config->getSchemas (); |
|
| 124 | - foreach ( $schemas as $schema ) { |
|
| 125 | - $arrUrl = array ( |
|
| 123 | + $schemas = $this->config->getSchemas(); |
|
| 124 | + foreach ($schemas as $schema) { |
|
| 125 | + $arrUrl = array( |
|
| 126 | 126 | $this->baseLocation, |
| 127 | 127 | $driverBase, |
| 128 | 128 | $folderName, |
| 129 | - $this->getClassName ( $schema ) |
|
| 129 | + $this->getClassName($schema) |
|
| 130 | 130 | ); |
| 131 | 131 | |
| 132 | - $this->location[ $schema ] = $this->filterLocation ( $arrUrl ); |
|
| 133 | - unset( $arrUrl ); |
|
| 132 | + $this->location[$schema] = $this->filterLocation($arrUrl); |
|
| 133 | + unset($arrUrl); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | } |
| 137 | 137 | else { |
| 138 | - $url = array ( |
|
| 138 | + $url = array( |
|
| 139 | 139 | $this->baseLocation, |
| 140 | 140 | $driverBase, |
| 141 | 141 | $folderName, |
| 142 | - $this->getClassName ( |
|
| 143 | - $this->getConfig () |
|
| 144 | - ->getDatabase () |
|
| 142 | + $this->getClassName( |
|
| 143 | + $this->getConfig() |
|
| 144 | + ->getDatabase() |
|
| 145 | 145 | ) |
| 146 | 146 | ); |
| 147 | - $this->location = array ( $this->filterLocation ( $url ) ); |
|
| 148 | - unset( $url ); |
|
| 147 | + $this->location = array($this->filterLocation($url)); |
|
| 148 | + unset($url); |
|
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
| 153 | 153 | * @return AdapterConfig\AbstractAdapter |
| 154 | 154 | */ |
| 155 | - public function getConfig () |
|
| 155 | + public function getConfig() |
|
| 156 | 156 | { |
| 157 | 157 | return $this->config; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /* Get current time */ |
| 161 | - public function startTime () |
|
| 161 | + public function startTime() |
|
| 162 | 162 | { |
| 163 | 163 | echo "Starting..\n"; |
| 164 | - $this->startTime = microtime ( true ); |
|
| 164 | + $this->startTime = microtime(true); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - private function getRunTime () |
|
| 167 | + private function getRunTime() |
|
| 168 | 168 | { |
| 169 | - return round ( ( microtime ( true ) - $this->startTime ), 3 ); |
|
| 169 | + return round((microtime(true) - $this->startTime), 3); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
| 173 | 173 | * Executa o Make, criando arquivos e Diretorios |
| 174 | 174 | */ |
| 175 | - public function run () |
|
| 175 | + public function run() |
|
| 176 | 176 | { |
| 177 | - $this->startTime (); |
|
| 178 | - $this->driver->runDatabase (); |
|
| 179 | - $this->max = $this->driver->getTotalTables () * $this->countDiretory (); |
|
| 177 | + $this->startTime(); |
|
| 178 | + $this->driver->runDatabase(); |
|
| 179 | + $this->max = $this->driver->getTotalTables() * $this->countDiretory(); |
|
| 180 | 180 | $cur = 0; |
| 181 | 181 | |
| 182 | 182 | |
| 183 | - foreach ( $this->location as $schema => $location ) { |
|
| 184 | - foreach ( $this->factoryMakerFile () as $objMakeFile ) { |
|
| 185 | - $path = $location . DIRECTORY_SEPARATOR . $objMakeFile->getPastName (); |
|
| 186 | - self::makeDir ( $path ); |
|
| 187 | - if ( $objMakeFile->getParentFileTpl () != '' ) { |
|
| 183 | + foreach ($this->location as $schema => $location) { |
|
| 184 | + foreach ($this->factoryMakerFile() as $objMakeFile) { |
|
| 185 | + $path = $location . DIRECTORY_SEPARATOR . $objMakeFile->getPastName(); |
|
| 186 | + self::makeDir($path); |
|
| 187 | + if ($objMakeFile->getParentFileTpl() != '') { |
|
| 188 | 188 | $fileAbstract = $this->baseLocation |
| 189 | 189 | . DIRECTORY_SEPARATOR |
| 190 | - . $objMakeFile->getParentClass () |
|
| 190 | + . $objMakeFile->getParentClass() |
|
| 191 | 191 | . '.php'; |
| 192 | 192 | |
| 193 | - $tplAbstract = $this->getParsedTplContents ( $objMakeFile->getParentFileTpl () ); |
|
| 194 | - self::makeSourcer ( $fileAbstract, $tplAbstract, true ); |
|
| 195 | - unset( $fileAbstract, $tplAbstract ); |
|
| 193 | + $tplAbstract = $this->getParsedTplContents($objMakeFile->getParentFileTpl()); |
|
| 194 | + self::makeSourcer($fileAbstract, $tplAbstract, true); |
|
| 195 | + unset($fileAbstract, $tplAbstract); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - foreach ( $this->driver->getTables ( $schema ) as $key => $objTables ) { |
|
| 199 | - $file = $path . DIRECTORY_SEPARATOR . self::getClassName ( $objTables->getName () ) . '.php'; |
|
| 198 | + foreach ($this->driver->getTables($schema) as $key => $objTables) { |
|
| 199 | + $file = $path . DIRECTORY_SEPARATOR . self::getClassName($objTables->getName()) . '.php'; |
|
| 200 | 200 | |
| 201 | - $tpl = $this->getParsedTplContents ( |
|
| 202 | - $objMakeFile->getFileTpl (), |
|
| 203 | - $objMakeFile->parseRelation ( $this, $objTables ), |
|
| 201 | + $tpl = $this->getParsedTplContents( |
|
| 202 | + $objMakeFile->getFileTpl(), |
|
| 203 | + $objMakeFile->parseRelation($this, $objTables), |
|
| 204 | 204 | $objTables, |
| 205 | 205 | $objMakeFile |
| 206 | 206 | |
| 207 | 207 | ); |
| 208 | - self::makeSourcer ( $file, $tpl, $objMakeFile->isOverwrite () ); |
|
| 209 | - $this->countCreatedFiles ( $cur ); |
|
| 208 | + self::makeSourcer($file, $tpl, $objMakeFile->isOverwrite()); |
|
| 209 | + $this->countCreatedFiles($cur); |
|
| 210 | 210 | } |
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - $this->reportProcess ( $cur ); |
|
| 214 | + $this->reportProcess($cur); |
|
| 215 | 215 | echo "\n\033[1;32mSuccessfully process finished!\n\033[0m"; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - private function countCreatedFiles ( &$cur ) |
|
| 218 | + private function countCreatedFiles(&$cur) |
|
| 219 | 219 | { |
| 220 | 220 | ++$cur; |
| 221 | - $total = ( $cur / $this->max ) * 100; |
|
| 222 | - printf ( "\r Creating: %6.2f%%", $total ); |
|
| 221 | + $total = ($cur / $this->max) * 100; |
|
| 222 | + printf("\r Creating: %6.2f%%", $total); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - private function reportProcess ( $countFiles ) |
|
| 225 | + private function reportProcess($countFiles) |
|
| 226 | 226 | { |
| 227 | - if ( $this->config->isStatusEnabled () ) { |
|
| 228 | - $databases = count ( $this->location ); |
|
| 229 | - $countDir = $this->countDiretory (); |
|
| 230 | - $totalTable = $this->driver->getTotalTables (); |
|
| 227 | + if ($this->config->isStatusEnabled()) { |
|
| 228 | + $databases = count($this->location); |
|
| 229 | + $countDir = $this->countDiretory(); |
|
| 230 | + $totalTable = $this->driver->getTotalTables(); |
|
| 231 | 231 | echo "\n------"; |
| 232 | - printf ( "\n\r-Files generated:%s of %s", $countFiles, $this->max ); |
|
| 233 | - printf ( "\n\r-Diretory generated:%s", $databases * $countDir ); |
|
| 234 | - printf ( "\n\r-Scanned tables:%s", $totalTable ); |
|
| 235 | - printf ( "\n\r-Execution time: %ssec", $this->getRunTime () ); |
|
| 232 | + printf("\n\r-Files generated:%s of %s", $countFiles, $this->max); |
|
| 233 | + printf("\n\r-Diretory generated:%s", $databases * $countDir); |
|
| 234 | + printf("\n\r-Scanned tables:%s", $totalTable); |
|
| 235 | + printf("\n\r-Execution time: %ssec", $this->getRunTime()); |
|
| 236 | 236 | echo "\n------"; |
| 237 | 237 | } |
| 238 | 238 | } |
@@ -242,9 +242,9 @@ discard block |
||
| 242 | 242 | * |
| 243 | 243 | * @return AbstractAdapter[] |
| 244 | 244 | */ |
| 245 | - public function factoryMakerFile () |
|
| 245 | + public function factoryMakerFile() |
|
| 246 | 246 | { |
| 247 | - return $this->config->getMakeFileInstances (); |
|
| 247 | + return $this->config->getMakeFileInstances(); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -252,11 +252,11 @@ discard block |
||
| 252 | 252 | * |
| 253 | 253 | * @return int |
| 254 | 254 | */ |
| 255 | - public function countDiretory () |
|
| 255 | + public function countDiretory() |
|
| 256 | 256 | { |
| 257 | 257 | $dir = 1; |
| 258 | - foreach ( $this->factoryMakerFile () as $abstractAdapter ) { |
|
| 259 | - if ( $abstractAdapter->hasDiretory () ) { |
|
| 258 | + foreach ($this->factoryMakerFile() as $abstractAdapter) { |
|
| 259 | + if ($abstractAdapter->hasDiretory()) { |
|
| 260 | 260 | ++$dir; |
| 261 | 261 | } |
| 262 | 262 | } |
@@ -272,24 +272,24 @@ discard block |
||
| 272 | 272 | * |
| 273 | 273 | * @return String |
| 274 | 274 | */ |
| 275 | - protected function getParsedTplContents ( $tplFile, $vars = array (), \Classes\Db\DbTable $objTables = null, |
|
| 276 | - $objMakeFile = null ) |
|
| 275 | + protected function getParsedTplContents($tplFile, $vars = array(), \Classes\Db\DbTable $objTables = null, |
|
| 276 | + $objMakeFile = null) |
|
| 277 | 277 | { |
| 278 | 278 | |
| 279 | - $arrUrl = array ( |
|
| 279 | + $arrUrl = array( |
|
| 280 | 280 | __DIR__, |
| 281 | 281 | 'templates', |
| 282 | 282 | $this->config->framework, |
| 283 | 283 | $tplFile |
| 284 | 284 | ); |
| 285 | 285 | |
| 286 | - $filePath = implode ( DIRECTORY_SEPARATOR, filter_var_array ( $arrUrl ) ); |
|
| 286 | + $filePath = implode(DIRECTORY_SEPARATOR, filter_var_array($arrUrl)); |
|
| 287 | 287 | |
| 288 | - extract ( $vars ); |
|
| 289 | - ob_start (); |
|
| 288 | + extract($vars); |
|
| 289 | + ob_start(); |
|
| 290 | 290 | require $filePath; |
| 291 | - $data = ob_get_contents (); |
|
| 292 | - ob_end_clean (); |
|
| 291 | + $data = ob_get_contents(); |
|
| 292 | + ob_end_clean(); |
|
| 293 | 293 | |
| 294 | 294 | return $data; |
| 295 | 295 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?= "<?php\n" ?> |
| 2 | -<?php $className = $objTables->getNamespace () . '_Entity_' . \Classes\Maker\AbstractMaker::getClassName ( |
|
| 3 | - $objTables->getName () |
|
| 2 | +<?php $className = $objTables->getNamespace() . '_Entity_' . \Classes\Maker\AbstractMaker::getClassName( |
|
| 3 | + $objTables->getName() |
|
| 4 | 4 | ) ?> |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | * |
| 9 | 9 | * <?= $this->config->last_modify . "\n" ?> |
| 10 | 10 | * |
| 11 | -* @package <?= $objTables->getNamespace () . "\n" ?> |
|
| 11 | +* @package <?= $objTables->getNamespace() . "\n" ?> |
|
| 12 | 12 | * @subpackage Entity |
| 13 | 13 | * |
| 14 | 14 | * @author <?= $this->config->author . "\n" ?> |
@@ -24,16 +24,16 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | 26 | abstract class <?= $className ?> extends <?= $this->config->namespace ? $this->config->namespace |
| 27 | - . "_" : "" ?>Model_<?= $objMakeFile->getParentClass ( |
|
| 27 | + . "_" : "" ?>Model_<?= $objMakeFile->getParentClass( |
|
| 28 | 28 | ) . "\n" ?> |
| 29 | 29 | { |
| 30 | 30 | |
| 31 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
| 31 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
| 32 | 32 | /** |
| 33 | - * Database constraint in the column <?= $column->getName () . "\n" ?> |
|
| 33 | + * Database constraint in the column <?= $column->getName() . "\n" ?> |
|
| 34 | 34 | * |
| 35 | 35 | */ |
| 36 | - const <?= strtoupper ( $column->getName () ) ?> = '<?= $objTables->getName () ?>.<?= $column->getName () ?>'; |
|
| 36 | + const <?= strtoupper($column->getName()) ?> = '<?= $objTables->getName() ?>.<?= $column->getName() ?>'; |
|
| 37 | 37 | <?php endforeach; ?> |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -42,17 +42,17 @@ discard block |
||
| 42 | 42 | * @var string |
| 43 | 43 | * @access protected |
| 44 | 44 | */ |
| 45 | -protected $_tableClass = '<?= $objTables->getNamespace () ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName ( |
|
| 46 | - $objTables->getName () |
|
| 45 | +protected $_tableClass = '<?= $objTables->getNamespace() ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName( |
|
| 46 | + $objTables->getName() |
|
| 47 | 47 | ) ?>'; |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * @see <?= $this->config->namespace ?>Model_EntityAbstract::$_columnsList |
| 51 | 51 | */ |
| 52 | 52 | protected $_columnsList = array( |
| 53 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
| 54 | - self::<?= strtoupper ( $column->getName () ) ?> => '<?= strtolower ( |
|
| 55 | - \Classes\Maker\AbstractMaker::getClassName ( $column->getName () ) |
|
| 53 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
| 54 | + self::<?= strtoupper($column->getName()) ?> => '<?= strtolower( |
|
| 55 | + \Classes\Maker\AbstractMaker::getClassName($column->getName()) |
|
| 56 | 56 | ) ?>', |
| 57 | 57 | <?php endforeach; ?> |
| 58 | 58 | ); |
@@ -61,10 +61,10 @@ discard block |
||
| 61 | 61 | * @see <?= $this->config->namespace ?>Model_EntityAbstract::$_filters |
| 62 | 62 | */ |
| 63 | 63 | protected $_filters = array( |
| 64 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
| 64 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
| 65 | 65 | <?php |
| 66 | 66 | $filters = null; |
| 67 | - switch ( ucfirst ( $column->getType () ) ) { |
|
| 67 | + switch (ucfirst($column->getType())) { |
|
| 68 | 68 | case 'String': |
| 69 | 69 | $filters = 'StripTags", "StringTrim'; |
| 70 | 70 | break; |
@@ -74,12 +74,12 @@ discard block |
||
| 74 | 74 | case 'Date': |
| 75 | 75 | break; |
| 76 | 76 | default: |
| 77 | - $filters = ucfirst ( $column->getType () ); |
|
| 77 | + $filters = ucfirst($column->getType()); |
|
| 78 | 78 | break; |
| 79 | 79 | } |
| 80 | 80 | ?> |
| 81 | - '<?= $column->getName () ?>'=>array ( |
|
| 82 | - <?= ( !empty( $filters ) ) ? "\"{$filters}\"\n" : null; ?> |
|
| 81 | + '<?= $column->getName() ?>'=>array ( |
|
| 82 | + <?= ( ! empty($filters)) ? "\"{$filters}\"\n" : null; ?> |
|
| 83 | 83 | ), |
| 84 | 84 | <?php endforeach; ?> |
| 85 | 85 | ); |
@@ -88,34 +88,34 @@ discard block |
||
| 88 | 88 | * @see <?= $this->config->namespace ?>Model_EntityAbstract::$_validators |
| 89 | 89 | */ |
| 90 | 90 | protected $_validators= array( |
| 91 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
| 91 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
| 92 | 92 | <?php |
| 93 | - $validators = array (); |
|
| 93 | + $validators = array(); |
|
| 94 | 94 | |
| 95 | - $validators[] = $column->isNullable () ? "'allowEmpty' => true" : "'NotEmpty'"; |
|
| 95 | + $validators[] = $column->isNullable() ? "'allowEmpty' => true" : "'NotEmpty'"; |
|
| 96 | 96 | |
| 97 | - switch ( ucfirst ( $column->getType () ) ) { |
|
| 97 | + switch (ucfirst($column->getType())) { |
|
| 98 | 98 | case 'String': |
| 99 | - if ( $column->getMaxLength () ) { |
|
| 100 | - $validators[] = "array( 'StringLength', array( 'max' => " . $column->getMaxLength () . " ) )"; |
|
| 99 | + if ($column->getMaxLength()) { |
|
| 100 | + $validators[] = "array( 'StringLength', array( 'max' => " . $column->getMaxLength() . " ) )"; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | break; |
| 104 | 104 | case 'Boolean': |
| 105 | 105 | break; |
| 106 | 106 | default: |
| 107 | - $name = ucfirst ( $column->getType () ); |
|
| 107 | + $name = ucfirst($column->getType()); |
|
| 108 | 108 | $validators[] = "'$name'"; |
| 109 | 109 | break; |
| 110 | 110 | } |
| 111 | - $validators = implode ( ", ", $validators ) ?> |
|
| 112 | - '<?= $column->getName () ?>' => array ( |
|
| 113 | - <?= ( !empty( $validators ) ) ? "{$validators}\n" : null ?> |
|
| 111 | + $validators = implode(", ", $validators) ?> |
|
| 112 | + '<?= $column->getName() ?>' => array ( |
|
| 113 | + <?= ( ! empty($validators)) ? "{$validators}\n" : null ?> |
|
| 114 | 114 | ), |
| 115 | 115 | <?php endforeach; ?> |
| 116 | 116 | ); |
| 117 | 117 | |
| 118 | -<?php if ( $objTables->hasPrimaryKey () ): ?> |
|
| 118 | +<?php if ($objTables->hasPrimaryKey()): ?> |
|
| 119 | 119 | /** |
| 120 | 120 | * Nome da Primary Key |
| 121 | 121 | * |
@@ -124,78 +124,78 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | |
| 126 | 126 | protected $_primary = array( |
| 127 | - <?php foreach ( $objTables->getPrimarykeys () as $pks ) : ?> |
|
| 128 | - '<?= $pks->getName () ?>', |
|
| 127 | + <?php foreach ($objTables->getPrimarykeys() as $pks) : ?> |
|
| 128 | + '<?= $pks->getName() ?>', |
|
| 129 | 129 | <?php endforeach ?> |
| 130 | 130 | ); |
| 131 | 131 | <?php endif ?> |
| 132 | 132 | |
| 133 | -<?php foreach ( $parents as $parent ): ?> |
|
| 133 | +<?php foreach ($parents as $parent): ?> |
|
| 134 | 134 | /** |
| 135 | - * Parent relation <?= \Classes\Maker\AbstractMaker::getClassName ( $parent[ 'table' ] ) . "\n" ?> |
|
| 135 | + * Parent relation <?= \Classes\Maker\AbstractMaker::getClassName($parent['table']) . "\n" ?> |
|
| 136 | 136 | * |
| 137 | - * @var <?= $parent[ 'name' ] . "\n" ?> |
|
| 137 | + * @var <?= $parent['name'] . "\n" ?> |
|
| 138 | 138 | */ |
| 139 | - protected $_parent_<?= $parent[ 'name' ] ?>; |
|
| 139 | + protected $_parent_<?= $parent['name'] ?>; |
|
| 140 | 140 | |
| 141 | 141 | <?php endforeach; ?> |
| 142 | -<?php foreach ( $depends as $depend ): ?> |
|
| 142 | +<?php foreach ($depends as $depend): ?> |
|
| 143 | 143 | /** |
| 144 | - * Depends relation <?= \Classes\Maker\AbstractMaker::getClassName ( $depend[ 'table' ] ) . "\n" ?> |
|
| 144 | + * Depends relation <?= \Classes\Maker\AbstractMaker::getClassName($depend['table']) . "\n" ?> |
|
| 145 | 145 | * |
| 146 | - * @var <?= $depend[ 'class' ] . "\n" ?> |
|
| 146 | + * @var <?= $depend['class'] . "\n" ?> |
|
| 147 | 147 | */ |
| 148 | - protected $_depend_<?= $depend[ 'name' ] ?>; |
|
| 148 | + protected $_depend_<?= $depend['name'] ?>; |
|
| 149 | 149 | |
| 150 | 150 | <?php endforeach; ?> |
| 151 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
| 151 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
| 152 | 152 | /** |
| 153 | 153 | * |
| 154 | - * Sets column <?= $column->getName () . "\n" ?> |
|
| 154 | + * Sets column <?= $column->getName() . "\n" ?> |
|
| 155 | 155 | * |
| 156 | - <?php if ( $column->equalType ( 'date' ) ): ?> |
|
| 156 | + <?php if ($column->equalType('date')): ?> |
|
| 157 | 157 | * Stored in ISO 8601 format. |
| 158 | 158 | * |
| 159 | - * @param string|Zend_Date $<?= $column->getName () . "\n" ?> |
|
| 159 | + * @param string|Zend_Date $<?= $column->getName() . "\n" ?> |
|
| 160 | 160 | <?php else: ?> |
| 161 | - * @param <?= $column->getType () ?> $<?= $column->getName () . "\n" ?> |
|
| 161 | + * @param <?= $column->getType() ?> $<?= $column->getName() . "\n" ?> |
|
| 162 | 162 | <?php endif; ?> |
| 163 | 163 | * @return <?= $className . "\n" ?> |
| 164 | 164 | */ |
| 165 | - public function set<?= \Classes\Maker\AbstractMaker::getClassName ( $column->getName () ) ?>($<?= $column->getName ( |
|
| 165 | + public function set<?= \Classes\Maker\AbstractMaker::getClassName($column->getName()) ?>($<?= $column->getName( |
|
| 166 | 166 | ) ?>) |
| 167 | 167 | { |
| 168 | - <?php switch ( $column->getType () ): |
|
| 168 | + <?php switch ($column->getType()): |
|
| 169 | 169 | case 'date': ?> |
| 170 | - if (! empty($<?= $column->getName () ?>)) |
|
| 170 | + if (! empty($<?= $column->getName() ?>)) |
|
| 171 | 171 | { |
| 172 | - if (! $<?= $column->getName () ?> instanceof Zend_Date) |
|
| 172 | + if (! $<?= $column->getName() ?> instanceof Zend_Date) |
|
| 173 | 173 | { |
| 174 | - $<?= $column->getName () ?> = new Zend_Date($<?= $column->getName () ?>); |
|
| 174 | + $<?= $column->getName() ?> = new Zend_Date($<?= $column->getName() ?>); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - $this-><?= $column->getName () ?> = $<?= $column->getName () ?>->toString(Zend_Date::ISO_8601); |
|
| 177 | + $this-><?= $column->getName() ?> = $<?= $column->getName() ?>->toString(Zend_Date::ISO_8601); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | <?php break ?> |
| 181 | 181 | <?php case 'boolean': ?> |
| 182 | - $this-><?= $column->getName () ?> = $<?= $column->getName () ?> ? true : false; |
|
| 182 | + $this-><?= $column->getName() ?> = $<?= $column->getName() ?> ? true : false; |
|
| 183 | 183 | |
| 184 | 184 | <?php break ?> |
| 185 | 185 | <?php default: ?> |
| 186 | - $<?= $column->getName () ?> = (<?= ucfirst ( $column->getType () ) ?>) $<?= $column->getName () ?> ; |
|
| 187 | - $input = new Zend_Filter_Input($this->_filters, $this->_validators, array('<?= $column->getName ( |
|
| 188 | - ) ?>'=>$<?= $column->getName () ?> )); |
|
| 189 | - if(!$input->isValid ('<?= $column->getName () ?>')) |
|
| 186 | + $<?= $column->getName() ?> = (<?= ucfirst($column->getType()) ?>) $<?= $column->getName() ?> ; |
|
| 187 | + $input = new Zend_Filter_Input($this->_filters, $this->_validators, array('<?= $column->getName( |
|
| 188 | + ) ?>'=>$<?= $column->getName() ?> )); |
|
| 189 | + if(!$input->isValid ('<?= $column->getName() ?>')) |
|
| 190 | 190 | { |
| 191 | 191 | $errors = $input->getMessages (); |
| 192 | - foreach ( $errors['<?= $column->getName () ?>'] as $key => $value ) |
|
| 192 | + foreach ( $errors['<?= $column->getName() ?>'] as $key => $value ) |
|
| 193 | 193 | { |
| 194 | 194 | throw new Exception ( $value ); |
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - $this-><?= $column->getName () ?> = $<?= $column->getName () ?> ; |
|
| 198 | + $this-><?= $column->getName() ?> = $<?= $column->getName() ?> ; |
|
| 199 | 199 | |
| 200 | 200 | <?php break ?> |
| 201 | 201 | <?php endswitch ?> |
@@ -203,72 +203,72 @@ discard block |
||
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
| 206 | - * Gets column <?= $column->getName () . "\n" ?> |
|
| 206 | + * Gets column <?= $column->getName() . "\n" ?> |
|
| 207 | 207 | * |
| 208 | - <?php if ( $column->equalType ( 'date' ) ): ?> |
|
| 208 | + <?php if ($column->equalType('date')): ?> |
|
| 209 | 209 | * @param boolean $returnZendDate |
| 210 | 210 | * @return Zend_Date|null|string Zend_Date representation of this datetime if enabled, or ISO 8601 string if not |
| 211 | 211 | <?php else: ?> |
| 212 | - * @return <?= $column->getType () . "\n" ?> |
|
| 212 | + * @return <?= $column->getType() . "\n" ?> |
|
| 213 | 213 | <?php endif; ?> |
| 214 | 214 | */ |
| 215 | - public function get<?= \Classes\Maker\AbstractMaker::getClassName ( |
|
| 216 | - $column->getName () |
|
| 217 | - ) ?>(<?php if ( $column->equalType ( 'date' ) ): ?>$returnZendDate = false <?php endif; ?>) |
|
| 215 | + public function get<?= \Classes\Maker\AbstractMaker::getClassName( |
|
| 216 | + $column->getName() |
|
| 217 | + ) ?>(<?php if ($column->equalType('date')): ?>$returnZendDate = false <?php endif; ?>) |
|
| 218 | 218 | { |
| 219 | - <?php if ( $column->equalType ( 'date' ) ): ?> |
|
| 219 | + <?php if ($column->equalType('date')): ?> |
|
| 220 | 220 | if ($returnZendDate) |
| 221 | 221 | { |
| 222 | - if ($this->_data['<?= $column->getName () ?>'] === null) |
|
| 222 | + if ($this->_data['<?= $column->getName() ?>'] === null) |
|
| 223 | 223 | { |
| 224 | 224 | return null; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - return new Zend_Date($this-><?= $column->getName () ?>, Zend_Date::ISO_8601); |
|
| 227 | + return new Zend_Date($this-><?= $column->getName() ?>, Zend_Date::ISO_8601); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | <?php endif; ?> |
| 231 | - return $this-><?= $column->getName () ?>; |
|
| 231 | + return $this-><?= $column->getName() ?>; |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | <?php endforeach; ?> |
| 235 | -<?php foreach ( $parents as $parent ): ?> |
|
| 235 | +<?php foreach ($parents as $parent): ?> |
|
| 236 | 236 | /** |
| 237 | - * Gets parent <?= $parent[ 'table' ] . "\n" ?> |
|
| 237 | + * Gets parent <?= $parent['table'] . "\n" ?> |
|
| 238 | 238 | * |
| 239 | - * @return <?= $parent[ 'class' ] . "\n" ?> |
|
| 239 | + * @return <?= $parent['class'] . "\n" ?> |
|
| 240 | 240 | */ |
| 241 | - public function get<?= $parent[ 'function' ] ?>() |
|
| 241 | + public function get<?= $parent['function'] ?>() |
|
| 242 | 242 | { |
| 243 | - if ($this->_parent_<?= $parent[ 'name' ] ?> === null) |
|
| 243 | + if ($this->_parent_<?= $parent['name'] ?> === null) |
|
| 244 | 244 | { |
| 245 | - $this->_parent_<?= $parent[ 'name' ] ?> = $this->findParentRow('<?= $objTables->getNamespace ( |
|
| 246 | - ) ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName ( |
|
| 247 | - $parent[ 'table' ] |
|
| 248 | - ) ?>', '<?= \Classes\Maker\AbstractMaker::getClassName ( $parent[ 'name' ] ) ?>'); |
|
| 245 | + $this->_parent_<?= $parent['name'] ?> = $this->findParentRow('<?= $objTables->getNamespace( |
|
| 246 | + ) ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName( |
|
| 247 | + $parent['table'] |
|
| 248 | + ) ?>', '<?= \Classes\Maker\AbstractMaker::getClassName($parent['name']) ?>'); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - return $this->_parent_<?= $parent[ 'name' ] ?>; |
|
| 251 | + return $this->_parent_<?= $parent['name'] ?>; |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | <?php endforeach; ?> |
| 255 | 255 | |
| 256 | 256 | |
| 257 | -<?php foreach ( $depends as $depend ): ?> |
|
| 257 | +<?php foreach ($depends as $depend): ?> |
|
| 258 | 258 | /** |
| 259 | - * Gets dependent <?= $depend[ 'table' ] . "\n" ?> |
|
| 259 | + * Gets dependent <?= $depend['table'] . "\n" ?> |
|
| 260 | 260 | * |
| 261 | - * @return <?= $depend[ 'class' ] . "\n" ?> |
|
| 261 | + * @return <?= $depend['class'] . "\n" ?> |
|
| 262 | 262 | */ |
| 263 | - public function get<?= $depend[ 'function' ] ?>() |
|
| 263 | + public function get<?= $depend['function'] ?>() |
|
| 264 | 264 | { |
| 265 | - if ($this->_depend_<?= $depend[ 'name' ] ?> === null) |
|
| 265 | + if ($this->_depend_<?= $depend['name'] ?> === null) |
|
| 266 | 266 | { |
| 267 | - $this->_depend_<?= $depend[ 'name' ] ?> = $this->findDependentRowset('<?= $objTables->getNamespace ( |
|
| 268 | - ) ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName ( $depend[ 'table' ] ) ?>'); |
|
| 267 | + $this->_depend_<?= $depend['name'] ?> = $this->findDependentRowset('<?= $objTables->getNamespace( |
|
| 268 | + ) ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName($depend['table']) ?>'); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - return $this->_depend_<?= $depend[ 'name' ] ?>; |
|
| 271 | + return $this->_depend_<?= $depend['name'] ?>; |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | <?php endforeach; ?> |
@@ -157,9 +157,12 @@ discard block |
||
| 157 | 157 | * Stored in ISO 8601 format. |
| 158 | 158 | * |
| 159 | 159 | * @param string|Zend_Date $<?= $column->getName () . "\n" ?> |
| 160 | - <?php else: ?> |
|
| 160 | + <?php else { |
|
| 161 | + : ?> |
|
| 161 | 162 | * @param <?= $column->getType () ?> $<?= $column->getName () . "\n" ?> |
| 162 | - <?php endif; ?> |
|
| 163 | + <?php endif; |
|
| 164 | +} |
|
| 165 | +?> |
|
| 163 | 166 | * @return <?= $className . "\n" ?> |
| 164 | 167 | */ |
| 165 | 168 | public function set<?= \Classes\Maker\AbstractMaker::getClassName ( $column->getName () ) ?>($<?= $column->getName ( |
@@ -208,9 +211,12 @@ discard block |
||
| 208 | 211 | <?php if ( $column->equalType ( 'date' ) ): ?> |
| 209 | 212 | * @param boolean $returnZendDate |
| 210 | 213 | * @return Zend_Date|null|string Zend_Date representation of this datetime if enabled, or ISO 8601 string if not |
| 211 | - <?php else: ?> |
|
| 214 | + <?php else { |
|
| 215 | + : ?> |
|
| 212 | 216 | * @return <?= $column->getType () . "\n" ?> |
| 213 | - <?php endif; ?> |
|
| 217 | + <?php endif; |
|
| 218 | +} |
|
| 219 | +?> |
|
| 214 | 220 | */ |
| 215 | 221 | public function get<?= \Classes\Maker\AbstractMaker::getClassName ( |
| 216 | 222 | $column->getName () |
@@ -3,43 +3,43 @@ discard block |
||
| 3 | 3 | /** |
| 4 | 4 | * Mvc Model |
| 5 | 5 | * |
| 6 | - * <?=$this->config->last_modify."\n"?> |
|
| 6 | + * <?=$this->config->last_modify . "\n"?> |
|
| 7 | 7 | * |
| 8 | 8 | * @package <?=$objTables->getNamespace()?>\Entity |
| 9 | 9 | * @subpackage Model |
| 10 | - * @author <?=$this->config->author."\n"?> |
|
| 10 | + * @author <?=$this->config->author . "\n"?> |
|
| 11 | 11 | * |
| 12 | - * @copyright <?=$this->config->copyright."\n"?> |
|
| 13 | - * @license <?=$this->config->license."\n"?> |
|
| 14 | - * @link <?=$this->config->link."\n"?> |
|
| 15 | - * @version <?=$this->config->version."\n"?> |
|
| 12 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
| 13 | + * @license <?=$this->config->license . "\n"?> |
|
| 14 | + * @link <?=$this->config->link . "\n"?> |
|
| 15 | + * @version <?=$this->config->version . "\n"?> |
|
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | namespace <?=$objTables->getNamespace()?>\Entity; |
| 19 | 19 | |
| 20 | 20 | use Phalcon\Validation; |
| 21 | 21 | |
| 22 | -abstract class <?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?> extends \<?=$this->config->namespace?$this->config->namespace."\\":""?>Models\<?=$objMakeFile->getParentClass() . "\n"?> |
|
| 22 | +abstract class <?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?> extends \<?=$this->config->namespace ? $this->config->namespace . "\\" : ""?>Models\<?=$objMakeFile->getParentClass() . "\n"?> |
|
| 23 | 23 | { |
| 24 | 24 | |
| 25 | 25 | <?php foreach ($objTables->getColumns() as $column): ?> |
| 26 | 26 | /** |
| 27 | - * column <?=$column->getName()."\n"?> |
|
| 27 | + * column <?=$column->getName() . "\n"?> |
|
| 28 | 28 | * |
| 29 | -<?php if($column->isPrimaryKey()):?> |
|
| 29 | +<?php if ($column->isPrimaryKey()):?> |
|
| 30 | 30 | * @Primary |
| 31 | 31 | <?php endif ?> |
| 32 | -<?php if($column->hasSequence()):?> |
|
| 32 | +<?php if ($column->hasSequence()):?> |
|
| 33 | 33 | * @Identity |
| 34 | 34 | <?php endif ?> |
| 35 | - * @Column(type="<?=$column->getTypeByConfig( $this->config )?>", nullable=<?=$column->isNullable () ? "true" : "false"?><?php |
|
| 36 | -if ( $column->getMaxLength () ): ?> |
|
| 37 | -, length=<?=$column->getMaxLength ()?> |
|
| 35 | + * @Column(type="<?=$column->getTypeByConfig($this->config)?>", nullable=<?=$column->isNullable() ? "true" : "false"?><?php |
|
| 36 | +if ($column->getMaxLength()): ?> |
|
| 37 | +, length=<?=$column->getMaxLength()?> |
|
| 38 | 38 | <?php endif ?>, column="<?=$column->getName()?>" ) |
| 39 | 39 | */ |
| 40 | 40 | protected $<?=$column->getName()?>; |
| 41 | 41 | |
| 42 | -<?php endforeach;?> |
|
| 42 | +<?php endforeach; ?> |
|
| 43 | 43 | /** |
| 44 | 44 | * Validations and business logic |
| 45 | 45 | * |
@@ -50,14 +50,14 @@ discard block |
||
| 50 | 50 | $validator = new Validation(); |
| 51 | 51 | |
| 52 | 52 | <?php foreach ($objTables->getColumns() as $column): ?> |
| 53 | -<?php if(strtolower($column->getName()) == 'email'):?> |
|
| 53 | +<?php if (strtolower($column->getName()) == 'email'):?> |
|
| 54 | 54 | $validator->add( |
| 55 | 55 | 'email', |
| 56 | 56 | new \Phalcon\Validation\Validator\Email() |
| 57 | 57 | ); |
| 58 | 58 | |
| 59 | 59 | <?php endif ?> |
| 60 | -<?php endforeach;?> |
|
| 60 | +<?php endforeach; ?> |
|
| 61 | 61 | return $this->validate($validator); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -66,11 +66,11 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function initialize() |
| 68 | 68 | { |
| 69 | - <?=$mapDependents."\n"?> |
|
| 70 | - <?=$mapParents."\n"?> |
|
| 69 | + <?=$mapDependents . "\n"?> |
|
| 70 | + <?=$mapParents . "\n"?> |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | -<?php if($objTables->hasSchema()): ?> |
|
| 73 | +<?php if ($objTables->hasSchema()): ?> |
|
| 74 | 74 | /** |
| 75 | 75 | * Returns schema name where table mapped is located |
| 76 | 76 | * |
@@ -92,28 +92,28 @@ discard block |
||
| 92 | 92 | return '<?=$objTables->getName()?>'; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | -<?php if( $objTables->hasSequences() ) : ?> |
|
| 95 | +<?php if ($objTables->hasSequences()) : ?> |
|
| 96 | 96 | public function getSequenceName() |
| 97 | 97 | { |
| 98 | -<?php if ( 1 == count($objTables->getSequences() ) ) : ?> |
|
| 99 | - <?php $seqs = $objTables->getSequences();reset($seqs);$seq = current($seqs);?> |
|
| 98 | +<?php if (1 == count($objTables->getSequences())) : ?> |
|
| 99 | + <?php $seqs = $objTables->getSequences(); reset($seqs); $seq = current($seqs); ?> |
|
| 100 | 100 | return "<?=$seq->getSequence() ?>"; |
| 101 | 101 | <?php endif ?> |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | <?php endif ?> |
| 105 | 105 | <?php foreach ($objTables->getColumns() as $column): ?> |
| 106 | - public function set<?=$this->getClassName ( $column->getName () )?>( $<?=$column->getName()?> ) |
|
| 106 | + public function set<?=$this->getClassName($column->getName())?>( $<?=$column->getName()?> ) |
|
| 107 | 107 | { |
| 108 | 108 | $this-><?=$column->getName()?> = $<?=$column->getName()?>; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
| 112 | - * @return <?=$column->getType ()."\n" ?> |
|
| 112 | + * @return <?=$column->getType() . "\n" ?> |
|
| 113 | 113 | **/ |
| 114 | - public function get<?=$this->getClassName ( $column->getName () )?>() |
|
| 114 | + public function get<?=$this->getClassName($column->getName())?>() |
|
| 115 | 115 | { |
| 116 | - return (<?=$column->getType () ?>) $this-><?=$column->getName()?>; |
|
| 116 | + return (<?=$column->getType() ?>) $this-><?=$column->getName()?>; |
|
| 117 | 117 | } |
| 118 | -<?php endforeach;?> |
|
| 118 | +<?php endforeach; ?> |
|
| 119 | 119 | } |
| 120 | 120 | \ No newline at end of file |
@@ -169,10 +169,10 @@ discard block |
||
| 169 | 169 | if ( empty( $this->totalTables ) ) { |
| 170 | 170 | |
| 171 | 171 | $this->totalTables = $this->getPDO () |
| 172 | - ->query ( |
|
| 173 | - "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{$this->database}'" |
|
| 174 | - ) |
|
| 175 | - ->fetchColumn (); |
|
| 172 | + ->query ( |
|
| 173 | + "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{$this->database}'" |
|
| 174 | + ) |
|
| 175 | + ->fetchColumn (); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | return (int) $this->totalTables; |
@@ -189,10 +189,10 @@ discard block |
||
| 189 | 189 | public function getSequence ( $table, $column, $schema = 0 ) |
| 190 | 190 | { |
| 191 | 191 | $return = $this->getPDO () |
| 192 | - ->query ( |
|
| 193 | - "select * from information_schema.columns where extra like '%auto_increment%' and TABLE_SCHEMA='{$this->database}' AND TABLE_NAME='{$table}' AND COLUMN_NAME='{$column}';" |
|
| 194 | - ) |
|
| 195 | - ->fetch ( \PDO::FETCH_ASSOC ); |
|
| 192 | + ->query ( |
|
| 193 | + "select * from information_schema.columns where extra like '%auto_increment%' and TABLE_SCHEMA='{$this->database}' AND TABLE_NAME='{$table}' AND COLUMN_NAME='{$column}';" |
|
| 194 | + ) |
|
| 195 | + ->fetch ( \PDO::FETCH_ASSOC ); |
|
| 196 | 196 | |
| 197 | 197 | if ( !$return ) { |
| 198 | 198 | return; |
@@ -30,28 +30,28 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return string |
| 32 | 32 | */ |
| 33 | - protected function convertTypeToSimple ( $str ) |
|
| 33 | + protected function convertTypeToSimple($str) |
|
| 34 | 34 | { |
| 35 | 35 | $res = ''; |
| 36 | - if ( preg_match ( '/(tinyint\(1\)|bit)/', $str ) ) { |
|
| 36 | + if (preg_match('/(tinyint\(1\)|bit)/', $str)) { |
|
| 37 | 37 | $res = 'boolean'; |
| 38 | 38 | } |
| 39 | - elseif ( preg_match ( '/(timestamp|blob|char|enum)/', $str ) ) { |
|
| 39 | + elseif (preg_match('/(timestamp|blob|char|enum)/', $str)) { |
|
| 40 | 40 | $res = 'string'; |
| 41 | 41 | } |
| 42 | - elseif ( preg_match ( '/(text)/', $str ) ) { |
|
| 42 | + elseif (preg_match('/(text)/', $str)) { |
|
| 43 | 43 | $res = 'text'; |
| 44 | 44 | } |
| 45 | - elseif ( preg_match ( '/(decimal|numeric|float|double)/', $str ) ) { |
|
| 45 | + elseif (preg_match('/(decimal|numeric|float|double)/', $str)) { |
|
| 46 | 46 | $res = 'float'; |
| 47 | 47 | } |
| 48 | - elseif ( preg_match ( '#^(?:tiny|small|medium|long|big|var)?(\w+)(?:\(\d+\))?(?:\s\w+)*$#', $str, $matches ) ) { |
|
| 49 | - $res = $matches[ 1 ]; |
|
| 48 | + elseif (preg_match('#^(?:tiny|small|medium|long|big|var)?(\w+)(?:\(\d+\))?(?:\s\w+)*$#', $str, $matches)) { |
|
| 49 | + $res = $matches[1]; |
|
| 50 | 50 | } |
| 51 | - elseif ( preg_match ( '/(date)/', $str ) ) { |
|
| 51 | + elseif (preg_match('/(date)/', $str)) { |
|
| 52 | 52 | $res = 'date'; |
| 53 | 53 | } |
| 54 | - elseif ( preg_match ( '/(datetime)/', $str ) ) { |
|
| 54 | + elseif (preg_match('/(datetime)/', $str)) { |
|
| 55 | 55 | $res = 'datetime'; |
| 56 | 56 | } |
| 57 | 57 | else { |
@@ -65,9 +65,9 @@ discard block |
||
| 65 | 65 | * @inheritDoc |
| 66 | 66 | * @return string |
| 67 | 67 | */ |
| 68 | - public function getPDOString () |
|
| 68 | + public function getPDOString() |
|
| 69 | 69 | { |
| 70 | - return sprintf ( |
|
| 70 | + return sprintf( |
|
| 71 | 71 | "mysql:host=%s;port=%s;dbname=%s", |
| 72 | 72 | $this->host, |
| 73 | 73 | $this->port, |
@@ -80,9 +80,9 @@ discard block |
||
| 80 | 80 | * @inheritDoc |
| 81 | 81 | * @return string |
| 82 | 82 | */ |
| 83 | - public function getPDOSocketString () |
|
| 83 | + public function getPDOSocketString() |
|
| 84 | 84 | { |
| 85 | - return sprintf ( |
|
| 85 | + return sprintf( |
|
| 86 | 86 | "mysql:unix_socket=%s;dbname=%s", |
| 87 | 87 | $this->socket, |
| 88 | 88 | $this->database |
@@ -94,14 +94,14 @@ discard block |
||
| 94 | 94 | * @inheritDoc |
| 95 | 95 | * @return string[] |
| 96 | 96 | */ |
| 97 | - public function getListNameTable () |
|
| 97 | + public function getListNameTable() |
|
| 98 | 98 | { |
| 99 | - if ( empty( $this->tableList ) ) { |
|
| 100 | - $this->tableList = $this->getPDO () |
|
| 101 | - ->query ( |
|
| 99 | + if (empty($this->tableList)) { |
|
| 100 | + $this->tableList = $this->getPDO() |
|
| 101 | + ->query( |
|
| 102 | 102 | "show tables" |
| 103 | 103 | ) |
| 104 | - ->fetchAll (); |
|
| 104 | + ->fetchAll(); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | return $this->tableList; |
@@ -112,11 +112,11 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | * @return array[] |
| 114 | 114 | */ |
| 115 | - public function getListColumns () |
|
| 115 | + public function getListColumns() |
|
| 116 | 116 | { |
| 117 | 117 | |
| 118 | - return $this->getPDO () |
|
| 119 | - ->query ( |
|
| 118 | + return $this->getPDO() |
|
| 119 | + ->query( |
|
| 120 | 120 | "select |
| 121 | 121 | 0 AS table_schema, |
| 122 | 122 | table_name, |
@@ -128,16 +128,16 @@ discard block |
||
| 128 | 128 | where table_schema IN ('{$this->database}') |
| 129 | 129 | order by table_name,ordinal_position" |
| 130 | 130 | ) |
| 131 | - ->fetchAll ( \PDO::FETCH_ASSOC ); |
|
| 131 | + ->fetchAll(\PDO::FETCH_ASSOC); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
| 135 | 135 | * @return array |
| 136 | 136 | */ |
| 137 | - public function getListConstrant () |
|
| 137 | + public function getListConstrant() |
|
| 138 | 138 | { |
| 139 | - return $this->getPDO () |
|
| 140 | - ->query ( |
|
| 139 | + return $this->getPDO() |
|
| 140 | + ->query( |
|
| 141 | 141 | "SELECT distinct |
| 142 | 142 | i.constraint_type, |
| 143 | 143 | k.constraint_name, |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | i.TABLE_SCHEMA IN ('{$this->database}') AND i.CONSTRAINT_TYPE IN ('FOREIGN KEY', 'PRIMARY KEY' ) |
| 157 | 157 | order by k.table_schema, k.table_name;" |
| 158 | 158 | ) |
| 159 | - ->fetchAll ( \PDO::FETCH_ASSOC ); |
|
| 159 | + ->fetchAll(\PDO::FETCH_ASSOC); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -164,15 +164,15 @@ discard block |
||
| 164 | 164 | * |
| 165 | 165 | * @return int |
| 166 | 166 | */ |
| 167 | - public function getTotalTables () |
|
| 167 | + public function getTotalTables() |
|
| 168 | 168 | { |
| 169 | - if ( empty( $this->totalTables ) ) { |
|
| 169 | + if (empty($this->totalTables)) { |
|
| 170 | 170 | |
| 171 | - $this->totalTables = $this->getPDO () |
|
| 172 | - ->query ( |
|
| 171 | + $this->totalTables = $this->getPDO() |
|
| 172 | + ->query( |
|
| 173 | 173 | "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{$this->database}'" |
| 174 | 174 | ) |
| 175 | - ->fetchColumn (); |
|
| 175 | + ->fetchColumn(); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | return (int) $this->totalTables; |
@@ -186,15 +186,15 @@ discard block |
||
| 186 | 186 | * |
| 187 | 187 | * @return string |
| 188 | 188 | */ |
| 189 | - public function getSequence ( $table, $column, $schema = 0 ) |
|
| 189 | + public function getSequence($table, $column, $schema = 0) |
|
| 190 | 190 | { |
| 191 | - $return = $this->getPDO () |
|
| 192 | - ->query ( |
|
| 191 | + $return = $this->getPDO() |
|
| 192 | + ->query( |
|
| 193 | 193 | "select * from information_schema.columns where extra like '%auto_increment%' and TABLE_SCHEMA='{$this->database}' AND TABLE_NAME='{$table}' AND COLUMN_NAME='{$column}';" |
| 194 | 194 | ) |
| 195 | - ->fetch ( \PDO::FETCH_ASSOC ); |
|
| 195 | + ->fetch(\PDO::FETCH_ASSOC); |
|
| 196 | 196 | |
| 197 | - if ( !$return ) { |
|
| 197 | + if ( ! $return) { |
|
| 198 | 198 | return; |
| 199 | 199 | } |
| 200 | 200 | |
@@ -35,26 +35,19 @@ |
||
| 35 | 35 | $res = ''; |
| 36 | 36 | if ( preg_match ( '/(tinyint\(1\)|bit)/', $str ) ) { |
| 37 | 37 | $res = 'boolean'; |
| 38 | - } |
|
| 39 | - elseif ( preg_match ( '/(timestamp|blob|char|enum)/', $str ) ) { |
|
| 38 | + } elseif ( preg_match ( '/(timestamp|blob|char|enum)/', $str ) ) { |
|
| 40 | 39 | $res = 'string'; |
| 41 | - } |
|
| 42 | - elseif ( preg_match ( '/(text)/', $str ) ) { |
|
| 40 | + } elseif ( preg_match ( '/(text)/', $str ) ) { |
|
| 43 | 41 | $res = 'text'; |
| 44 | - } |
|
| 45 | - elseif ( preg_match ( '/(decimal|numeric|float|double)/', $str ) ) { |
|
| 42 | + } elseif ( preg_match ( '/(decimal|numeric|float|double)/', $str ) ) { |
|
| 46 | 43 | $res = 'float'; |
| 47 | - } |
|
| 48 | - elseif ( preg_match ( '#^(?:tiny|small|medium|long|big|var)?(\w+)(?:\(\d+\))?(?:\s\w+)*$#', $str, $matches ) ) { |
|
| 44 | + } elseif ( preg_match ( '#^(?:tiny|small|medium|long|big|var)?(\w+)(?:\(\d+\))?(?:\s\w+)*$#', $str, $matches ) ) { |
|
| 49 | 45 | $res = $matches[ 1 ]; |
| 50 | - } |
|
| 51 | - elseif ( preg_match ( '/(date)/', $str ) ) { |
|
| 46 | + } elseif ( preg_match ( '/(date)/', $str ) ) { |
|
| 52 | 47 | $res = 'date'; |
| 53 | - } |
|
| 54 | - elseif ( preg_match ( '/(datetime)/', $str ) ) { |
|
| 48 | + } elseif ( preg_match ( '/(datetime)/', $str ) ) { |
|
| 55 | 49 | $res = 'datetime'; |
| 56 | - } |
|
| 57 | - else { |
|
| 50 | + } else { |
|
| 58 | 51 | print "Can't convert column type to Simple - Unrecognized type: $str"; |
| 59 | 52 | } |
| 60 | 53 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | $pdo = $this->getPDO (); |
| 173 | 173 | $return1 = $pdo->query ( "SELECT pg_get_serial_sequence('$tableTemp', '$column');" ) |
| 174 | - ->fetchColumn (); |
|
| 174 | + ->fetchColumn (); |
|
| 175 | 175 | |
| 176 | 176 | if ( !is_null ( $return1 ) ) { |
| 177 | 177 | return $return1; |
@@ -247,14 +247,14 @@ discard block |
||
| 247 | 247 | $strSchema = implode ( "', '", $this->schema ); |
| 248 | 248 | |
| 249 | 249 | $this->totalTables = $this->getPDO () |
| 250 | - ->query ( |
|
| 251 | - "SELECT COUNT(table_name) AS total |
|
| 250 | + ->query ( |
|
| 251 | + "SELECT COUNT(table_name) AS total |
|
| 252 | 252 | FROM information_schema.tables |
| 253 | 253 | WHERE |
| 254 | 254 | table_type = 'BASE TABLE' |
| 255 | 255 | AND table_schema IN ( '" . $strSchema . "' )" |
| 256 | - ) |
|
| 257 | - ->fetchColumn (); |
|
| 256 | + ) |
|
| 257 | + ->fetchColumn (); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | return (int) $this->totalTables; |
@@ -27,9 +27,9 @@ discard block |
||
| 27 | 27 | /** |
| 28 | 28 | * @type array|\string[] |
| 29 | 29 | */ |
| 30 | - protected $schema = array ( 'public' ); |
|
| 30 | + protected $schema = array('public'); |
|
| 31 | 31 | |
| 32 | - protected $dataTypesToSimple = array ( |
|
| 32 | + protected $dataTypesToSimple = array( |
|
| 33 | 33 | /* Numeric Types */ |
| 34 | 34 | 'smallint' => 'int', |
| 35 | 35 | 'integer' => 'int', |
@@ -57,11 +57,11 @@ discard block |
||
| 57 | 57 | 'boolean' => 'boolean' |
| 58 | 58 | ); |
| 59 | 59 | |
| 60 | - public function __construct ( AbstractAdapter $adapterConfig ) |
|
| 60 | + public function __construct(AbstractAdapter $adapterConfig) |
|
| 61 | 61 | { |
| 62 | - parent::__construct ( $adapterConfig ); |
|
| 63 | - if ( $adapterConfig->hasSchemas () ) { |
|
| 64 | - $this->schema = $adapterConfig->getSchemas (); |
|
| 62 | + parent::__construct($adapterConfig); |
|
| 63 | + if ($adapterConfig->hasSchemas()) { |
|
| 64 | + $this->schema = $adapterConfig->getSchemas(); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | } |
@@ -73,13 +73,13 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @return string[] |
| 75 | 75 | */ |
| 76 | - public function getListNameTable () |
|
| 76 | + public function getListNameTable() |
|
| 77 | 77 | { |
| 78 | - if ( empty( $this->tableList ) ) { |
|
| 79 | - $strSchema = implode ( "', '", $this->schema ); |
|
| 78 | + if (empty($this->tableList)) { |
|
| 79 | + $strSchema = implode("', '", $this->schema); |
|
| 80 | 80 | |
| 81 | - $this->tableList = $this->getPDO () |
|
| 82 | - ->query ( |
|
| 81 | + $this->tableList = $this->getPDO() |
|
| 82 | + ->query( |
|
| 83 | 83 | "SELECT table_schema, |
| 84 | 84 | table_name |
| 85 | 85 | FROM information_schema.tables |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | table_name |
| 92 | 92 | ASC" |
| 93 | 93 | ) |
| 94 | - ->fetchAll (); |
|
| 94 | + ->fetchAll(); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | return $this->tableList; |
@@ -102,12 +102,12 @@ discard block |
||
| 102 | 102 | * |
| 103 | 103 | * @return array |
| 104 | 104 | */ |
| 105 | - public function getListColumns () |
|
| 105 | + public function getListColumns() |
|
| 106 | 106 | { |
| 107 | - $strSchema = implode ( "', '", $this->schema ); |
|
| 107 | + $strSchema = implode("', '", $this->schema); |
|
| 108 | 108 | |
| 109 | - return $this->getPDO () |
|
| 110 | - ->query ( |
|
| 109 | + return $this->getPDO() |
|
| 110 | + ->query( |
|
| 111 | 111 | "SELECT distinct |
| 112 | 112 | c.table_schema, |
| 113 | 113 | c.table_name, |
@@ -122,15 +122,15 @@ discard block |
||
| 122 | 122 | and c.table_schema IN ('$strSchema') |
| 123 | 123 | order by c.table_name asc" |
| 124 | 124 | ) |
| 125 | - ->fetchAll ( \PDO::FETCH_ASSOC ); |
|
| 125 | + ->fetchAll(\PDO::FETCH_ASSOC); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - public function getListConstrant () |
|
| 128 | + public function getListConstrant() |
|
| 129 | 129 | { |
| 130 | - $strSchema = implode ( "', '", $this->schema ); |
|
| 130 | + $strSchema = implode("', '", $this->schema); |
|
| 131 | 131 | |
| 132 | - return $this->getPDO () |
|
| 133 | - ->query ( |
|
| 132 | + return $this->getPDO() |
|
| 133 | + ->query( |
|
| 134 | 134 | "SELECT distinct |
| 135 | 135 | tc.constraint_type, |
| 136 | 136 | tc.constraint_name, |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | AND tc.constraint_schema = ccu.constraint_schema |
| 152 | 152 | ORDER by tc.table_schema" |
| 153 | 153 | ) |
| 154 | - ->fetchAll ( \PDO::FETCH_ASSOC ); |
|
| 154 | + ->fetchAll(\PDO::FETCH_ASSOC); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -162,22 +162,22 @@ discard block |
||
| 162 | 162 | * |
| 163 | 163 | * @return string |
| 164 | 164 | */ |
| 165 | - public function getSequence ( $table, $column, $schema = 0 ) |
|
| 165 | + public function getSequence($table, $column, $schema = 0) |
|
| 166 | 166 | { |
| 167 | 167 | $tableTemp = $table; |
| 168 | - if ( 0 !== $schema ) { |
|
| 168 | + if (0 !== $schema) { |
|
| 169 | 169 | $tableTemp = $schema . '.' . $table; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - $pdo = $this->getPDO (); |
|
| 173 | - $return1 = $pdo->query ( "SELECT pg_get_serial_sequence('$tableTemp', '$column');" ) |
|
| 174 | - ->fetchColumn (); |
|
| 172 | + $pdo = $this->getPDO(); |
|
| 173 | + $return1 = $pdo->query("SELECT pg_get_serial_sequence('$tableTemp', '$column');") |
|
| 174 | + ->fetchColumn(); |
|
| 175 | 175 | |
| 176 | - if ( !is_null ( $return1 ) ) { |
|
| 176 | + if ( ! is_null($return1)) { |
|
| 177 | 177 | return $return1; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - $stmt = $pdo->prepare ( |
|
| 180 | + $stmt = $pdo->prepare( |
|
| 181 | 181 | "SELECT distinct adsrc FROM pg_attrdef AS att |
| 182 | 182 | INNER JOIN pg_class AS c |
| 183 | 183 | ON adrelid = c.oid AND c.relname = ? --table |
@@ -188,15 +188,15 @@ discard block |
||
| 188 | 188 | " |
| 189 | 189 | ); |
| 190 | 190 | |
| 191 | - $stmt->bindParam ( 1, $table ); |
|
| 192 | - $stmt->bindParam ( 2, $column ); |
|
| 193 | - $stmt->bindParam ( 3, $schema ); |
|
| 194 | - $stmt->execute (); |
|
| 195 | - $return2 = $stmt->fetchColumn (); |
|
| 191 | + $stmt->bindParam(1, $table); |
|
| 192 | + $stmt->bindParam(2, $column); |
|
| 193 | + $stmt->bindParam(3, $schema); |
|
| 194 | + $stmt->execute(); |
|
| 195 | + $return2 = $stmt->fetchColumn(); |
|
| 196 | 196 | |
| 197 | - if ( $return2 ) { |
|
| 198 | - return preg_filter ( |
|
| 199 | - array ( |
|
| 197 | + if ($return2) { |
|
| 198 | + return preg_filter( |
|
| 199 | + array( |
|
| 200 | 200 | '/nextval\(\'/', |
| 201 | 201 | '/\'::regclass\)/' |
| 202 | 202 | ), |
@@ -211,9 +211,9 @@ discard block |
||
| 211 | 211 | * @inheritDoc |
| 212 | 212 | * @return string |
| 213 | 213 | */ |
| 214 | - public function getPDOString () |
|
| 214 | + public function getPDOString() |
|
| 215 | 215 | { |
| 216 | - return sprintf ( |
|
| 216 | + return sprintf( |
|
| 217 | 217 | "pgsql:host=%s;port=%s;dbname=%s", |
| 218 | 218 | $this->host, |
| 219 | 219 | $this->port, |
@@ -226,9 +226,9 @@ discard block |
||
| 226 | 226 | * @inheritDoc |
| 227 | 227 | * @return string |
| 228 | 228 | */ |
| 229 | - public function getPDOSocketString () |
|
| 229 | + public function getPDOSocketString() |
|
| 230 | 230 | { |
| 231 | - return sprintf ( |
|
| 231 | + return sprintf( |
|
| 232 | 232 | "pgsql:unix_socket=%s;dbname=%s", |
| 233 | 233 | $this->socket, |
| 234 | 234 | $this->database |
@@ -241,20 +241,20 @@ discard block |
||
| 241 | 241 | * |
| 242 | 242 | * @return int |
| 243 | 243 | */ |
| 244 | - public function getTotalTables () |
|
| 244 | + public function getTotalTables() |
|
| 245 | 245 | { |
| 246 | - if ( empty( $this->totalTables ) ) { |
|
| 247 | - $strSchema = implode ( "', '", $this->schema ); |
|
| 246 | + if (empty($this->totalTables)) { |
|
| 247 | + $strSchema = implode("', '", $this->schema); |
|
| 248 | 248 | |
| 249 | - $this->totalTables = $this->getPDO () |
|
| 250 | - ->query ( |
|
| 249 | + $this->totalTables = $this->getPDO() |
|
| 250 | + ->query( |
|
| 251 | 251 | "SELECT COUNT(table_name) AS total |
| 252 | 252 | FROM information_schema.tables |
| 253 | 253 | WHERE |
| 254 | 254 | table_type = 'BASE TABLE' |
| 255 | 255 | AND table_schema IN ( '" . $strSchema . "' )" |
| 256 | 256 | ) |
| 257 | - ->fetchColumn (); |
|
| 257 | + ->fetchColumn(); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | return (int) $this->totalTables; |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | abstract class AbstractAdapter |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - protected $arrConfig = array ( |
|
| 19 | + protected $arrConfig = array( |
|
| 20 | 20 | ############################# DATABASE |
| 21 | 21 | //Driver do banco de dados |
| 22 | 22 | 'driver' => null, |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | //senha do banco |
| 32 | 32 | 'password' => null, |
| 33 | 33 | // lista de schemas do banco de dados |
| 34 | - 'schema' => array (), |
|
| 34 | + 'schema' => array(), |
|
| 35 | 35 | 'version' => '', |
| 36 | 36 | 'socket' => null, |
| 37 | 37 | |
@@ -64,13 +64,13 @@ discard block |
||
| 64 | 64 | // flags para criar todas as tabelas ou nao |
| 65 | 65 | 'allTables' => true, |
| 66 | 66 | //Lista de tabelas a serem ignoradas |
| 67 | - 'ignoreTable' => array (), |
|
| 67 | + 'ignoreTable' => array(), |
|
| 68 | 68 | ); |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * @var string[] um array com todos os campos obrigatorios |
| 72 | 72 | */ |
| 73 | - protected $attRequered = array ( |
|
| 73 | + protected $attRequered = array( |
|
| 74 | 74 | 'driver' => true, |
| 75 | 75 | 'database' => true, |
| 76 | 76 | 'host' => true, |
@@ -78,14 +78,14 @@ discard block |
||
| 78 | 78 | 'path' => true |
| 79 | 79 | ); |
| 80 | 80 | |
| 81 | - protected $arrFunc = array (); |
|
| 81 | + protected $arrFunc = array(); |
|
| 82 | 82 | |
| 83 | - private $framworkFiles = array (); |
|
| 83 | + private $framworkFiles = array(); |
|
| 84 | 84 | |
| 85 | - public $reservedWord = array (); |
|
| 85 | + public $reservedWord = array(); |
|
| 86 | 86 | |
| 87 | 87 | |
| 88 | - private static $dataTypesDefault = array ( |
|
| 88 | + private static $dataTypesDefault = array( |
|
| 89 | 89 | 'int' => 'int', |
| 90 | 90 | 'float' => 'float', |
| 91 | 91 | 'string' => 'string', |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | 'boolean' => 'boolean' |
| 96 | 96 | ); |
| 97 | 97 | |
| 98 | - protected $dataTypes = array (); |
|
| 98 | + protected $dataTypes = array(); |
|
| 99 | 99 | |
| 100 | 100 | const SEPARETOR = ""; |
| 101 | 101 | |
@@ -104,9 +104,9 @@ discard block |
||
| 104 | 104 | * |
| 105 | 105 | * @return bool |
| 106 | 106 | */ |
| 107 | - protected function checkConfig () |
|
| 107 | + protected function checkConfig() |
|
| 108 | 108 | { |
| 109 | - if ( array_diff_key ( $this->attRequered, array_filter ( $this->arrConfig ) ) ) { |
|
| 109 | + if (array_diff_key($this->attRequered, array_filter($this->arrConfig))) { |
|
| 110 | 110 | return false; |
| 111 | 111 | } |
| 112 | 112 | |
@@ -118,33 +118,33 @@ discard block |
||
| 118 | 118 | * |
| 119 | 119 | * @return array |
| 120 | 120 | */ |
| 121 | - abstract protected function getParams (); |
|
| 121 | + abstract protected function getParams(); |
|
| 122 | 122 | |
| 123 | 123 | /** |
| 124 | 124 | * Popula as config do generater com as configuraçoes do framework |
| 125 | 125 | * |
| 126 | 126 | * @return mixed |
| 127 | 127 | */ |
| 128 | - abstract protected function parseFrameworkConfig (); |
|
| 128 | + abstract protected function parseFrameworkConfig(); |
|
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | 131 | * Cria Instancias dos arquivos que devem ser gerados |
| 132 | 132 | * |
| 133 | 133 | * @return \Classes\AdapterMakerFile\AbstractAdapter[] |
| 134 | 134 | */ |
| 135 | - abstract public function getMakeFileInstances (); |
|
| 135 | + abstract public function getMakeFileInstances(); |
|
| 136 | 136 | |
| 137 | - abstract protected function init (); |
|
| 137 | + abstract protected function init(); |
|
| 138 | 138 | |
| 139 | 139 | /** |
| 140 | 140 | * retorna a base do Namespace |
| 141 | 141 | * |
| 142 | 142 | * @return array |
| 143 | 143 | */ |
| 144 | - protected function getBaseNamespace () |
|
| 144 | + protected function getBaseNamespace() |
|
| 145 | 145 | { |
| 146 | - return array ( |
|
| 147 | - $this->arrConfig[ 'namespace' ], |
|
| 146 | + return array( |
|
| 147 | + $this->arrConfig['namespace'], |
|
| 148 | 148 | 'Model' |
| 149 | 149 | ); |
| 150 | 150 | } |
@@ -155,49 +155,49 @@ discard block |
||
| 155 | 155 | * @return mixed |
| 156 | 156 | */ |
| 157 | 157 | |
| 158 | - public function createClassNamespace ( $table ) |
|
| 158 | + public function createClassNamespace($table) |
|
| 159 | 159 | { |
| 160 | - $arrNames = $this->getBaseNamespace (); |
|
| 160 | + $arrNames = $this->getBaseNamespace(); |
|
| 161 | 161 | |
| 162 | - if ( isset( $this->arrConfig[ 'folder-database' ] ) |
|
| 163 | - && $this->arrConfig[ 'folder-database' ] |
|
| 162 | + if (isset($this->arrConfig['folder-database']) |
|
| 163 | + && $this->arrConfig['folder-database'] |
|
| 164 | 164 | ) { |
| 165 | - $arrNames[] = AbstractMaker::getClassName ( $this->arrConfig[ 'driver' ] ); |
|
| 165 | + $arrNames[] = AbstractMaker::getClassName($this->arrConfig['driver']); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - if ( isset( $this->arrConfig[ 'folder-name' ] ) |
|
| 169 | - && $this->arrConfig[ 'folder-name' ] |
|
| 168 | + if (isset($this->arrConfig['folder-name']) |
|
| 169 | + && $this->arrConfig['folder-name'] |
|
| 170 | 170 | ) { |
| 171 | - $arrNames[] = AbstractMaker::getClassName ( $this->arrConfig[ 'folder-name' ] ); |
|
| 171 | + $arrNames[] = AbstractMaker::getClassName($this->arrConfig['folder-name']); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - if ( $table->hasSchema () ) { |
|
| 175 | - $arrNames[] = $this->replaceReservedWord ( AbstractMaker::getClassName ( $table->getSchema () ) ); |
|
| 174 | + if ($table->hasSchema()) { |
|
| 175 | + $arrNames[] = $this->replaceReservedWord(AbstractMaker::getClassName($table->getSchema())); |
|
| 176 | 176 | } |
| 177 | 177 | else { |
| 178 | - $arrNames[] = $this->replaceReservedWord ( AbstractMaker::getClassName ( $table->getDatabase () ) ); |
|
| 178 | + $arrNames[] = $this->replaceReservedWord(AbstractMaker::getClassName($table->getDatabase())); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - return implode ( static::SEPARETOR, array_filter ( $arrNames ) ); |
|
| 181 | + return implode(static::SEPARETOR, array_filter($arrNames)); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - public function __construct ( $array ) |
|
| 184 | + public function __construct($array) |
|
| 185 | 185 | { |
| 186 | 186 | $this->dataTypes = $this->dataTypes + self::$dataTypesDefault; |
| 187 | - $array += array ( |
|
| 187 | + $array += array( |
|
| 188 | 188 | 'version' => Config::$version, |
| 189 | - 'author' => ucfirst ( get_current_user () ), |
|
| 190 | - 'last_modify' => date ( "d-m-Y H:i:s." ) |
|
| 189 | + 'author' => ucfirst(get_current_user()), |
|
| 190 | + 'last_modify' => date("d-m-Y H:i:s.") |
|
| 191 | 191 | ); |
| 192 | 192 | |
| 193 | - $this->setFrameworkFiles ( $array ); |
|
| 194 | - $this->parseFrameworkConfig (); |
|
| 195 | - $this->setParams ( $this->getParams () ); |
|
| 196 | - $this->setParams ( $array ); |
|
| 197 | - $this->init (); |
|
| 198 | - if ( !$this->isValid () ) { |
|
| 199 | - $var = array_diff_key ( $this->attRequered, array_filter ( $this->arrConfig ) ); |
|
| 200 | - throw new Exception( $var ); |
|
| 193 | + $this->setFrameworkFiles($array); |
|
| 194 | + $this->parseFrameworkConfig(); |
|
| 195 | + $this->setParams($this->getParams()); |
|
| 196 | + $this->setParams($array); |
|
| 197 | + $this->init(); |
|
| 198 | + if ( ! $this->isValid()) { |
|
| 199 | + $var = array_diff_key($this->attRequered, array_filter($this->arrConfig)); |
|
| 200 | + throw new Exception($var); |
|
| 201 | 201 | } |
| 202 | 202 | } |
| 203 | 203 | |
@@ -206,35 +206,35 @@ discard block |
||
| 206 | 206 | * |
| 207 | 207 | * @param $array |
| 208 | 208 | */ |
| 209 | - public function setFrameworkFiles ( $array ) |
|
| 209 | + public function setFrameworkFiles($array) |
|
| 210 | 210 | { |
| 211 | - $this->framworkFiles[ 'library' ] = isset( $array[ 'framework-path-library' ] ) ? $array[ 'framework-path-library' ] : null; |
|
| 211 | + $this->framworkFiles['library'] = isset($array['framework-path-library']) ? $array['framework-path-library'] : null; |
|
| 212 | 212 | |
| 213 | - $this->framworkFiles[ 'ini' ] = isset( $array[ 'framework-ini' ] ) ? $array[ 'framework-ini' ] : null; |
|
| 213 | + $this->framworkFiles['ini'] = isset($array['framework-ini']) ? $array['framework-ini'] : null; |
|
| 214 | 214 | |
| 215 | - $this->framworkFiles[ 'environment' ] = isset( $array[ 'environment' ] ) ? $array[ 'environment' ] : 'production'; |
|
| 215 | + $this->framworkFiles['environment'] = isset($array['environment']) ? $array['environment'] : 'production'; |
|
| 216 | 216 | |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - protected function isValidFrameworkFiles () |
|
| 219 | + protected function isValidFrameworkFiles() |
|
| 220 | 220 | { |
| 221 | - if ( !is_file ( $this->framworkFiles[ 'ini' ] ) ) { |
|
| 221 | + if ( ! is_file($this->framworkFiles['ini'])) { |
|
| 222 | 222 | return false; |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - if ( !is_dir ( $this->framworkFiles[ 'library' ] ) ) { |
|
| 225 | + if ( ! is_dir($this->framworkFiles['library'])) { |
|
| 226 | 226 | return false; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - if ( !isset ( $this->framworkFiles[ 'environment' ] ) or empty( $this->framworkFiles[ 'environment' ] ) ) { |
|
| 229 | + if ( ! isset ($this->framworkFiles['environment']) or empty($this->framworkFiles['environment'])) { |
|
| 230 | 230 | return false; |
| 231 | 231 | } |
| 232 | - set_include_path ( |
|
| 233 | - implode ( |
|
| 232 | + set_include_path( |
|
| 233 | + implode( |
|
| 234 | 234 | PATH_SEPARATOR, |
| 235 | - array ( |
|
| 236 | - realpath ( $this->framworkFiles[ 'library' ] ), |
|
| 237 | - get_include_path (), |
|
| 235 | + array( |
|
| 236 | + realpath($this->framworkFiles['library']), |
|
| 237 | + get_include_path(), |
|
| 238 | 238 | ) |
| 239 | 239 | ) |
| 240 | 240 | ); |
@@ -242,110 +242,110 @@ discard block |
||
| 242 | 242 | return true; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - protected function getFrameworkIni () |
|
| 245 | + protected function getFrameworkIni() |
|
| 246 | 246 | { |
| 247 | - return $this->framworkFiles[ 'ini' ]; |
|
| 247 | + return $this->framworkFiles['ini']; |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - protected function getEnvironment () |
|
| 250 | + protected function getEnvironment() |
|
| 251 | 251 | { |
| 252 | - return $this->framworkFiles[ 'environment' ]; |
|
| 252 | + return $this->framworkFiles['environment']; |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | /** |
| 256 | 256 | * Popula as variaveis de acordo com o arquivo de configuração do seu framework |
| 257 | 257 | */ |
| 258 | - protected function isValid () |
|
| 258 | + protected function isValid() |
|
| 259 | 259 | { |
| 260 | - return $this->checkConfig (); |
|
| 260 | + return $this->checkConfig(); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - private function setParams ( $array ) |
|
| 263 | + private function setParams($array) |
|
| 264 | 264 | { |
| 265 | - if ( count ( $array ) > 0 ) { |
|
| 266 | - $this->arrConfig = array_filter ( $array ) + $this->arrConfig; |
|
| 265 | + if (count($array) > 0) { |
|
| 266 | + $this->arrConfig = array_filter($array) + $this->arrConfig; |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | /** |
| 271 | 271 | * @return string |
| 272 | 272 | */ |
| 273 | - public function getDatabase () |
|
| 273 | + public function getDatabase() |
|
| 274 | 274 | { |
| 275 | - return $this->arrConfig[ 'database' ]; |
|
| 275 | + return $this->arrConfig['database']; |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | /** |
| 279 | 279 | * @return bool |
| 280 | 280 | */ |
| 281 | - public function hasSchemas () |
|
| 281 | + public function hasSchemas() |
|
| 282 | 282 | { |
| 283 | - return !empty ( $this->arrConfig[ 'schema' ] ); |
|
| 283 | + return ! empty ($this->arrConfig['schema']); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
| 287 | 287 | * @return string[] |
| 288 | 288 | */ |
| 289 | - public function getSchemas () |
|
| 289 | + public function getSchemas() |
|
| 290 | 290 | { |
| 291 | - if ( is_string ( $this->arrConfig[ 'schema' ] ) ) { |
|
| 292 | - return array ( $this->arrConfig[ 'schema' ] ); |
|
| 291 | + if (is_string($this->arrConfig['schema'])) { |
|
| 292 | + return array($this->arrConfig['schema']); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | - return $this->arrConfig[ 'schema' ]; |
|
| 295 | + return $this->arrConfig['schema']; |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - public function setSchema ( $schema ) |
|
| 298 | + public function setSchema($schema) |
|
| 299 | 299 | { |
| 300 | - $this->arrConfig[ 'schema' ] = $schema; |
|
| 300 | + $this->arrConfig['schema'] = $schema; |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | /** |
| 304 | 304 | * @return string |
| 305 | 305 | */ |
| 306 | - public function getHost () |
|
| 306 | + public function getHost() |
|
| 307 | 307 | { |
| 308 | - return $this->arrConfig[ 'host' ]; |
|
| 308 | + return $this->arrConfig['host']; |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | /** |
| 312 | 312 | * @return int |
| 313 | 313 | */ |
| 314 | - public function getPort () |
|
| 314 | + public function getPort() |
|
| 315 | 315 | { |
| 316 | - return $this->arrConfig[ 'port' ]; |
|
| 316 | + return $this->arrConfig['port']; |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | /** |
| 320 | 320 | * @return boolean |
| 321 | 321 | */ |
| 322 | - public function hasPort () |
|
| 322 | + public function hasPort() |
|
| 323 | 323 | { |
| 324 | - return !empty( $this->arrConfig[ 'port' ] ); |
|
| 324 | + return ! empty($this->arrConfig['port']); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | /** |
| 328 | 328 | * @return string |
| 329 | 329 | */ |
| 330 | - public function getSocket () |
|
| 330 | + public function getSocket() |
|
| 331 | 331 | { |
| 332 | - return $this->arrConfig[ 'socket' ]; |
|
| 332 | + return $this->arrConfig['socket']; |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | /** |
| 336 | 336 | * @return string |
| 337 | 337 | */ |
| 338 | - public function getUser () |
|
| 338 | + public function getUser() |
|
| 339 | 339 | { |
| 340 | - return $this->arrConfig[ 'username' ]; |
|
| 340 | + return $this->arrConfig['username']; |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | /** |
| 344 | 344 | * @return string |
| 345 | 345 | */ |
| 346 | - public function getPassword () |
|
| 346 | + public function getPassword() |
|
| 347 | 347 | { |
| 348 | - return $this->arrConfig[ 'password' ]; |
|
| 348 | + return $this->arrConfig['password']; |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | /** |
@@ -353,10 +353,10 @@ discard block |
||
| 353 | 353 | * |
| 354 | 354 | * @return string |
| 355 | 355 | */ |
| 356 | - public function replaceReservedWord ( $palavra ) |
|
| 356 | + public function replaceReservedWord($palavra) |
|
| 357 | 357 | { |
| 358 | - if ( isset( $this->reservedWord[ strtolower ( $palavra ) ] ) ) { |
|
| 359 | - return $this->reservedWord[ strtolower ( $palavra ) ]; |
|
| 358 | + if (isset($this->reservedWord[strtolower($palavra)])) { |
|
| 359 | + return $this->reservedWord[strtolower($palavra)]; |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | return $palavra; |
@@ -365,9 +365,9 @@ discard block |
||
| 365 | 365 | /** |
| 366 | 366 | * @return bool |
| 367 | 367 | */ |
| 368 | - public function isStatusEnabled () |
|
| 368 | + public function isStatusEnabled() |
|
| 369 | 369 | { |
| 370 | - return (bool) $this->arrConfig[ 'status' ]; |
|
| 370 | + return (bool) $this->arrConfig['status']; |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | /** |
@@ -375,9 +375,9 @@ discard block |
||
| 375 | 375 | * |
| 376 | 376 | * @return string |
| 377 | 377 | */ |
| 378 | - public function __get ( $str ) |
|
| 378 | + public function __get($str) |
|
| 379 | 379 | { |
| 380 | - $arr = array ( |
|
| 380 | + $arr = array( |
|
| 381 | 381 | 'namespace', |
| 382 | 382 | 'framework', |
| 383 | 383 | 'author', |
@@ -391,8 +391,8 @@ discard block |
||
| 391 | 391 | 'folder-name' |
| 392 | 392 | ); |
| 393 | 393 | |
| 394 | - if ( in_array ( $str, $arr ) ) { |
|
| 395 | - return $this->arrConfig[ strtolower ( $str ) ]; |
|
| 394 | + if (in_array($str, $arr)) { |
|
| 395 | + return $this->arrConfig[strtolower($str)]; |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | return; |
@@ -403,9 +403,9 @@ discard block |
||
| 403 | 403 | * |
| 404 | 404 | * @return string |
| 405 | 405 | */ |
| 406 | - public static function convertTypeToPHP ( $type ) |
|
| 406 | + public static function convertTypeToPHP($type) |
|
| 407 | 407 | { |
| 408 | - return self::$dataTypesDefault[ $type ]; |
|
| 408 | + return self::$dataTypesDefault[$type]; |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | /** |
@@ -413,8 +413,8 @@ discard block |
||
| 413 | 413 | * |
| 414 | 414 | * @return string |
| 415 | 415 | */ |
| 416 | - public function convertTypeToTypeFramework ( $type ) |
|
| 416 | + public function convertTypeToTypeFramework($type) |
|
| 417 | 417 | { |
| 418 | - return $this->dataTypes[ $type ]; |
|
| 418 | + return $this->dataTypes[$type]; |
|
| 419 | 419 | } |
| 420 | 420 | } |
@@ -22,16 +22,16 @@ discard block |
||
| 22 | 22 | * @var string |
| 23 | 23 | */ |
| 24 | 24 | protected $framework = "phalcon"; |
| 25 | - public $reservedWord = array ( 'public' => 'Main' ); |
|
| 25 | + public $reservedWord = array('public' => 'Main'); |
|
| 26 | 26 | |
| 27 | - protected $dataTypes = array ( |
|
| 27 | + protected $dataTypes = array( |
|
| 28 | 28 | 'int' => 'integer', |
| 29 | 29 | 'float' => 'decimal' |
| 30 | 30 | ); |
| 31 | 31 | |
| 32 | 32 | const SEPARETOR = "\\"; |
| 33 | 33 | |
| 34 | - protected function init () |
|
| 34 | + protected function init() |
|
| 35 | 35 | { |
| 36 | 36 | } |
| 37 | 37 | |
@@ -40,12 +40,12 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @return array |
| 42 | 42 | */ |
| 43 | - protected function getParams () |
|
| 43 | + protected function getParams() |
|
| 44 | 44 | { |
| 45 | 45 | |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - protected function parseFrameworkConfig () |
|
| 48 | + protected function parseFrameworkConfig() |
|
| 49 | 49 | { |
| 50 | 50 | // TODO: Implement parseFrameworkConfig() method. |
| 51 | 51 | } |
@@ -53,10 +53,10 @@ discard block |
||
| 53 | 53 | /** |
| 54 | 54 | * @inheritdoc |
| 55 | 55 | */ |
| 56 | - protected function getBaseNamespace () |
|
| 56 | + protected function getBaseNamespace() |
|
| 57 | 57 | { |
| 58 | - return array ( |
|
| 59 | - $this->arrConfig[ 'namespace' ], |
|
| 58 | + return array( |
|
| 59 | + $this->arrConfig['namespace'], |
|
| 60 | 60 | 'Models' |
| 61 | 61 | ); |
| 62 | 62 | } |
@@ -66,12 +66,12 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @return \Classes\AdapterMakerFile\AbstractAdapter[] |
| 68 | 68 | */ |
| 69 | - public function getMakeFileInstances () |
|
| 69 | + public function getMakeFileInstances() |
|
| 70 | 70 | { |
| 71 | - return array ( |
|
| 72 | - Entity::getInstance (), |
|
| 73 | - Model::getInstance (), |
|
| 74 | - Peer::getInstance () |
|
| 71 | + return array( |
|
| 72 | + Entity::getInstance(), |
|
| 73 | + Model::getInstance(), |
|
| 74 | + Peer::getInstance() |
|
| 75 | 75 | ); |
| 76 | 76 | } |
| 77 | 77 | |