@@ -6,26 +6,26 @@ discard block |
||
| 6 | 6 | * @author Pedro Alarcao <[email protected]> |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -if ( ! ini_get ( 'short_open_tag' ) ) |
|
| 9 | +if ( ! ini_get('short_open_tag')) |
|
| 10 | 10 | { |
| 11 | - die( "please enable short_open_tag directive in php.ini\n" ); |
|
| 11 | + die("please enable short_open_tag directive in php.ini\n"); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | -if ( ! ini_get ( 'register_argc_argv' ) ) |
|
| 14 | +if ( ! ini_get('register_argc_argv')) |
|
| 15 | 15 | { |
| 16 | - die( "please enable register_argc_argv directive in php.ini\n" ); |
|
| 16 | + die("please enable register_argc_argv directive in php.ini\n"); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | |
| 20 | -if ( function_exists ( 'ini_set' ) ) |
|
| 20 | +if (function_exists('ini_set')) |
|
| 21 | 21 | { |
| 22 | - @ini_set ( 'display_errors' , 1 ); |
|
| 22 | + @ini_set('display_errors', 1); |
|
| 23 | 23 | |
| 24 | - $memoryInBytes = function ( $value ) |
|
| 24 | + $memoryInBytes = function($value) |
|
| 25 | 25 | { |
| 26 | - $unit = strtolower ( substr ( $value , - 1 , 1 ) ); |
|
| 26 | + $unit = strtolower(substr($value, - 1, 1)); |
|
| 27 | 27 | $value = (int) $value; |
| 28 | - switch ( $unit ) |
|
| 28 | + switch ($unit) |
|
| 29 | 29 | { |
| 30 | 30 | case 'g': |
| 31 | 31 | $value *= 1024; |
@@ -40,21 +40,21 @@ discard block |
||
| 40 | 40 | return $value; |
| 41 | 41 | }; |
| 42 | 42 | |
| 43 | - $memoryLimit = trim ( ini_get ( 'memory_limit' ) ); |
|
| 43 | + $memoryLimit = trim(ini_get('memory_limit')); |
|
| 44 | 44 | // Increase memory_limit if it is lower than 1GB |
| 45 | - if ( $memoryLimit != - 1 && $memoryInBytes( $memoryLimit ) < 1024 * 1024 * 1024 ) |
|
| 45 | + if ($memoryLimit != - 1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1024) |
|
| 46 | 46 | { |
| 47 | - @ini_set ( 'memory_limit' , '1G' ); |
|
| 47 | + @ini_set('memory_limit', '1G'); |
|
| 48 | 48 | } |
| 49 | - unset( $memoryInBytes , $memoryLimit ); |
|
| 49 | + unset($memoryInBytes, $memoryLimit); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | -set_include_path ( |
|
| 53 | - implode ( |
|
| 54 | - PATH_SEPARATOR , |
|
| 55 | - array ( |
|
| 56 | - realpath ( dirname ( __FILE__ ) . "/build/" ) , |
|
| 57 | - get_include_path () , |
|
| 52 | +set_include_path( |
|
| 53 | + implode( |
|
| 54 | + PATH_SEPARATOR, |
|
| 55 | + array( |
|
| 56 | + realpath(dirname(__FILE__) . "/build/"), |
|
| 57 | + get_include_path(), |
|
| 58 | 58 | ) |
| 59 | 59 | ) |
| 60 | 60 | ); |
@@ -65,34 +65,34 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | try |
| 67 | 67 | { |
| 68 | - $arrValid = array ( |
|
| 69 | - 'version' , |
|
| 70 | - 'help' , |
|
| 71 | - 'status' , |
|
| 72 | - 'init' , |
|
| 73 | - 'config-env:' , |
|
| 74 | - 'config-ini:' , |
|
| 75 | - 'database:' , |
|
| 76 | - 'schema:' , |
|
| 77 | - 'driver:' , |
|
| 78 | - 'framework:' , |
|
| 68 | + $arrValid = array( |
|
| 69 | + 'version', |
|
| 70 | + 'help', |
|
| 71 | + 'status', |
|
| 72 | + 'init', |
|
| 73 | + 'config-env:', |
|
| 74 | + 'config-ini:', |
|
| 75 | + 'database:', |
|
| 76 | + 'schema:', |
|
| 77 | + 'driver:', |
|
| 78 | + 'framework:', |
|
| 79 | 79 | 'path:' |
| 80 | 80 | ); |
| 81 | 81 | |
| 82 | - $_path = realpath ( __FILE__ ); |
|
| 83 | - $argv = getopt ( null , $arrValid ); |
|
| 82 | + $_path = realpath(__FILE__); |
|
| 83 | + $argv = getopt(null, $arrValid); |
|
| 84 | 84 | |
| 85 | - if ( array_key_exists ( 'init' , $argv ) ) |
|
| 85 | + if (array_key_exists('init', $argv)) |
|
| 86 | 86 | { |
| 87 | - $maker = new \Classes\MakerConfigFile( $argv , $_path ); |
|
| 87 | + $maker = new \Classes\MakerConfigFile($argv, $_path); |
|
| 88 | 88 | } else |
| 89 | 89 | { |
| 90 | - $maker = new \Classes\MakerFile( new \Classes\Config( $argv , $_path ) ); |
|
| 90 | + $maker = new \Classes\MakerFile(new \Classes\Config($argv, $_path)); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - $maker->run (); |
|
| 93 | + $maker->run(); |
|
| 94 | 94 | |
| 95 | -} catch ( \Exception $e ) |
|
| 95 | +} catch (\Exception $e) |
|
| 96 | 96 | { |
| 97 | - die( $e->getMessage () ); |
|
| 97 | + die($e->getMessage()); |
|
| 98 | 98 | } |
@@ -71,7 +71,6 @@ |
||
| 71 | 71 | /** |
| 72 | 72 | * Retorna um Array com nome das tabelas |
| 73 | 73 | * |
| 74 | - * @param void $schema |
|
| 75 | 74 | * |
| 76 | 75 | * @return string[] |
| 77 | 76 | */ |
@@ -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; |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | const SEPARETOR = "_"; |
| 24 | 24 | |
| 25 | - protected function init () |
|
| 25 | + protected function init() |
|
| 26 | 26 | { |
| 27 | 27 | } |
| 28 | 28 | |
@@ -31,50 +31,50 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | * @return array |
| 33 | 33 | */ |
| 34 | - protected function getParams () |
|
| 34 | + protected function getParams() |
|
| 35 | 35 | { |
| 36 | - if ( ! $this->config or ! $this->isValidFrameworkFiles () ) |
|
| 36 | + if ( ! $this->config or ! $this->isValidFrameworkFiles()) |
|
| 37 | 37 | { |
| 38 | - return array (); |
|
| 38 | + return array(); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - return array ( |
|
| 41 | + return array( |
|
| 42 | 42 | //Driver do banco de dados |
| 43 | - 'driver' => $this->config[ 'adapter' ] , |
|
| 43 | + 'driver' => $this->config['adapter'], |
|
| 44 | 44 | //Nome do banco de dados |
| 45 | - 'database' => $this->config[ 'params' ][ 'dbname' ] , |
|
| 45 | + 'database' => $this->config['params']['dbname'], |
|
| 46 | 46 | //Host do banco |
| 47 | - 'host' => $this->config[ 'params' ][ 'host' ] , |
|
| 47 | + 'host' => $this->config['params']['host'], |
|
| 48 | 48 | //Port do banco |
| 49 | - 'port' => isset( $this->config[ 'params' ][ 'port' ] ) |
|
| 50 | - ? $this->config[ 'params' ][ 'port' ] : '' , |
|
| 49 | + 'port' => isset($this->config['params']['port']) |
|
| 50 | + ? $this->config['params']['port'] : '', |
|
| 51 | 51 | //usuario do banco |
| 52 | - 'username' => $this->config[ 'params' ][ 'username' ] , |
|
| 52 | + 'username' => $this->config['params']['username'], |
|
| 53 | 53 | //senha do banco |
| 54 | - 'password' => $this->config[ 'params' ][ 'password' ] , |
|
| 54 | + 'password' => $this->config['params']['password'], |
|
| 55 | 55 | ); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - protected function parseFrameworkConfig () |
|
| 58 | + protected function parseFrameworkConfig() |
|
| 59 | 59 | { |
| 60 | - if ( ! $this->isValidFrameworkFiles () ) |
|
| 60 | + if ( ! $this->isValidFrameworkFiles()) |
|
| 61 | 61 | { |
| 62 | 62 | return; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - $frameworkIni = $this->getFrameworkIni (); |
|
| 65 | + $frameworkIni = $this->getFrameworkIni(); |
|
| 66 | 66 | |
| 67 | 67 | require_once 'Zend/Config/Ini.php'; |
| 68 | 68 | |
| 69 | 69 | $objConfig = new \Zend_Config_Ini( |
| 70 | - realpath ( $frameworkIni ) , $this->getEnvironment () |
|
| 70 | + realpath($frameworkIni), $this->getEnvironment() |
|
| 71 | 71 | ); |
| 72 | 72 | |
| 73 | - $arrConfig = $objConfig->toArray (); |
|
| 73 | + $arrConfig = $objConfig->toArray(); |
|
| 74 | 74 | |
| 75 | - if ( isset( $arrConfig[ 'resources' ][ 'db' ] ) ) |
|
| 75 | + if (isset($arrConfig['resources']['db'])) |
|
| 76 | 76 | { |
| 77 | - $this->config = $arrConfig[ 'resources' ][ 'db' ]; |
|
| 77 | + $this->config = $arrConfig['resources']['db']; |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
@@ -83,12 +83,12 @@ discard block |
||
| 83 | 83 | * |
| 84 | 84 | * @return \Classes\AdapterMakerFile\AbstractAdapter[] |
| 85 | 85 | */ |
| 86 | - public function getMakeFileInstances () |
|
| 86 | + public function getMakeFileInstances() |
|
| 87 | 87 | { |
| 88 | - return array ( |
|
| 89 | - DbTable::getInstance () , |
|
| 90 | - Entity::getInstance () , |
|
| 91 | - Model::getInstance () |
|
| 88 | + return array( |
|
| 89 | + DbTable::getInstance(), |
|
| 90 | + Entity::getInstance(), |
|
| 91 | + Model::getInstance() |
|
| 92 | 92 | ); |
| 93 | 93 | } |
| 94 | 94 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | const SEPARETOR = "_"; |
| 24 | 24 | |
| 25 | - protected function init () |
|
| 25 | + protected function init() |
|
| 26 | 26 | { |
| 27 | 27 | } |
| 28 | 28 | |
@@ -31,12 +31,12 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | * @return array |
| 33 | 33 | */ |
| 34 | - protected function getParams () |
|
| 34 | + protected function getParams() |
|
| 35 | 35 | { |
| 36 | 36 | |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - protected function parseFrameworkConfig () |
|
| 39 | + protected function parseFrameworkConfig() |
|
| 40 | 40 | { |
| 41 | 41 | // TODO: Implement parseFrameworkConfig() method. |
| 42 | 42 | } |
@@ -46,12 +46,12 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @return \Classes\AdapterMakerFile\AbstractAdapter[] |
| 48 | 48 | */ |
| 49 | - public function getMakeFileInstances () |
|
| 49 | + public function getMakeFileInstances() |
|
| 50 | 50 | { |
| 51 | - return array ( |
|
| 52 | - DbTable::getInstance (), |
|
| 53 | - Entity::getInstance (), |
|
| 54 | - Model::getInstance () |
|
| 51 | + return array( |
|
| 52 | + DbTable::getInstance(), |
|
| 53 | + Entity::getInstance(), |
|
| 54 | + Model::getInstance() |
|
| 55 | 55 | ); |
| 56 | 56 | } |
| 57 | 57 | |
@@ -19,6 +19,6 @@ |
||
| 19 | 19 | |
| 20 | 20 | public function parseRelation ( \Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable ) |
| 21 | 21 | { |
| 22 | - return array(); |
|
| 22 | + return array(); |
|
| 23 | 23 | } |
| 24 | 24 | } |
@@ -12,9 +12,9 @@ |
||
| 12 | 12 | /** |
| 13 | 13 | * @var void |
| 14 | 14 | */ |
| 15 | - protected $fileTpl = "model.php"; |
|
| 15 | + protected $fileTpl = "model.php"; |
|
| 16 | 16 | |
| 17 | - public function parseRelation ( \Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable ) |
|
| 17 | + public function parseRelation(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable) |
|
| 18 | 18 | { |
| 19 | 19 | return array(); |
| 20 | 20 | } |
@@ -70,6 +70,9 @@ |
||
| 70 | 70 | return $this; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | + /** |
|
| 74 | + * @return string |
|
| 75 | + */ |
|
| 73 | 76 | public function getDatabase (){ |
| 74 | 77 | return $this->database; |
| 75 | 78 | } |
@@ -21,11 +21,11 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @author Pedro Alarcao <[email protected]> |
| 23 | 23 | */ |
| 24 | - final private function __construct () |
|
| 24 | + final private function __construct() |
|
| 25 | 25 | { |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - public static function getInstance () |
|
| 28 | + public static function getInstance() |
|
| 29 | 29 | { |
| 30 | 30 | return new self(); |
| 31 | 31 | } |
@@ -55,34 +55,34 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @return Constrant |
| 57 | 57 | */ |
| 58 | - public function populate ( $array ) |
|
| 58 | + public function populate($array) |
|
| 59 | 59 | { |
| 60 | - if ( isset( $array[ 'schema' ] ) ) |
|
| 60 | + if (isset($array['schema'])) |
|
| 61 | 61 | { |
| 62 | - $this->schema = $array[ 'schema' ]; |
|
| 62 | + $this->schema = $array['schema']; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - $this->database = $array[ 'database' ]; |
|
| 66 | - $this->constrant = $array[ 'constrant' ]; |
|
| 67 | - $this->table = $array[ 'table' ]; |
|
| 68 | - $this->column = $array[ 'column' ]; |
|
| 65 | + $this->database = $array['database']; |
|
| 66 | + $this->constrant = $array['constrant']; |
|
| 67 | + $this->table = $array['table']; |
|
| 68 | + $this->column = $array['column']; |
|
| 69 | 69 | |
| 70 | 70 | return $this; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - public function getDatabase (){ |
|
| 73 | + public function getDatabase() { |
|
| 74 | 74 | return $this->database; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
| 78 | 78 | * @return string |
| 79 | 79 | */ |
| 80 | - public function getNameConstrant () |
|
| 80 | + public function getNameConstrant() |
|
| 81 | 81 | { |
| 82 | 82 | return $this->constrant; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - public function hasSchema () |
|
| 85 | + public function hasSchema() |
|
| 86 | 86 | { |
| 87 | 87 | return (bool) $this->schema; |
| 88 | 88 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | /** |
| 91 | 91 | * @return string |
| 92 | 92 | */ |
| 93 | - public function getSchema () |
|
| 93 | + public function getSchema() |
|
| 94 | 94 | { |
| 95 | 95 | return $this->schema; |
| 96 | 96 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | /** |
| 99 | 99 | * @return string |
| 100 | 100 | */ |
| 101 | - public function getTable () |
|
| 101 | + public function getTable() |
|
| 102 | 102 | { |
| 103 | 103 | return $this->table; |
| 104 | 104 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | /** |
| 107 | 107 | * @return string |
| 108 | 108 | */ |
| 109 | - public function getColumn () |
|
| 109 | + public function getColumn() |
|
| 110 | 110 | { |
| 111 | 111 | return $this->column; |
| 112 | 112 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | protected $fileTpl = "entity.php"; |
| 23 | 23 | protected $overwrite = true; |
| 24 | 24 | |
| 25 | - protected $validFunc = array (); |
|
| 25 | + protected $validFunc = array(); |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * @param \Classes\MakerFile $makerFile |
@@ -30,11 +30,11 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return array |
| 32 | 32 | */ |
| 33 | - public function parseRelation ( \Classes\MakerFile $makerFile , \Classes\Db\DbTable $dbTable ) |
|
| 33 | + public function parseRelation(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable) |
|
| 34 | 34 | { |
| 35 | - return array ( |
|
| 36 | - 'parents' => $this->listParents ( $makerFile , $dbTable ) , |
|
| 37 | - 'depends' => $this->listDependence ( $makerFile , $dbTable ) |
|
| 35 | + return array( |
|
| 36 | + 'parents' => $this->listParents($makerFile, $dbTable), |
|
| 37 | + 'depends' => $this->listDependence($makerFile, $dbTable) |
|
| 38 | 38 | ); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -44,35 +44,35 @@ discard block |
||
| 44 | 44 | * |
| 45 | 45 | * @return array |
| 46 | 46 | */ |
| 47 | - private function listParents ( \Classes\MakerFile $makerFile , \Classes\Db\DbTable $dbTable ) |
|
| 47 | + private function listParents(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable) |
|
| 48 | 48 | { |
| 49 | - $parents = array (); |
|
| 50 | - foreach ( $dbTable->getForeingkeys () as $objColumn ) |
|
| 49 | + $parents = array(); |
|
| 50 | + foreach ($dbTable->getForeingkeys() as $objColumn) |
|
| 51 | 51 | { |
| 52 | - $constrant = $objColumn->getFks (); |
|
| 52 | + $constrant = $objColumn->getFks(); |
|
| 53 | 53 | $name = |
| 54 | 54 | 'Parent' |
| 55 | 55 | . ZendFrameworkOne::SEPARETOR |
| 56 | - . AbstractMaker::getClassName ( $constrant->getTable () ) |
|
| 56 | + . AbstractMaker::getClassName($constrant->getTable()) |
|
| 57 | 57 | . ZendFrameworkOne::SEPARETOR |
| 58 | 58 | . 'By' |
| 59 | 59 | . ZendFrameworkOne::SEPARETOR |
| 60 | - . $objColumn->getName (); |
|
| 60 | + . $objColumn->getName(); |
|
| 61 | 61 | |
| 62 | - $arrClass = array ( |
|
| 63 | - $makerFile->getConfig ()->createClassNamespace ( $constrant ), |
|
| 64 | - AbstractMaker::getClassName ( $constrant->getTable () ) |
|
| 62 | + $arrClass = array( |
|
| 63 | + $makerFile->getConfig()->createClassNamespace($constrant), |
|
| 64 | + AbstractMaker::getClassName($constrant->getTable()) |
|
| 65 | 65 | ); |
| 66 | - $class = implode ( ZendFrameworkOne::SEPARETOR , array_filter ( $arrClass ) ); |
|
| 66 | + $class = implode(ZendFrameworkOne::SEPARETOR, array_filter($arrClass)); |
|
| 67 | 67 | |
| 68 | - $parents[] = array ( |
|
| 69 | - 'class' => $class , |
|
| 70 | - 'function' => AbstractMaker::getClassName ( $name ) , |
|
| 71 | - 'table' => $constrant->getTable () , |
|
| 72 | - 'column' => $objColumn->getName () , |
|
| 73 | - 'name' => $constrant->getNameConstrant () , |
|
| 68 | + $parents[] = array( |
|
| 69 | + 'class' => $class, |
|
| 70 | + 'function' => AbstractMaker::getClassName($name), |
|
| 71 | + 'table' => $constrant->getTable(), |
|
| 72 | + 'column' => $objColumn->getName(), |
|
| 73 | + 'name' => $constrant->getNameConstrant(), |
|
| 74 | 74 | ); |
| 75 | - unset( $name ); |
|
| 75 | + unset($name); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | return $parents; |
@@ -84,40 +84,40 @@ discard block |
||
| 84 | 84 | * |
| 85 | 85 | * @return array |
| 86 | 86 | */ |
| 87 | - private function listDependence ( \Classes\MakerFile $makerFile , \Classes\Db\DbTable $dbTable ) |
|
| 87 | + private function listDependence(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable) |
|
| 88 | 88 | { |
| 89 | - $depends = array (); |
|
| 90 | - foreach ( $dbTable->getDependences () as $objColumn ) |
|
| 89 | + $depends = array(); |
|
| 90 | + foreach ($dbTable->getDependences() as $objColumn) |
|
| 91 | 91 | { |
| 92 | - foreach ( $objColumn->getDependences () as $dependence ) |
|
| 92 | + foreach ($objColumn->getDependences() as $dependence) |
|
| 93 | 93 | { |
| 94 | 94 | $name = |
| 95 | 95 | 'Depend' |
| 96 | 96 | . ZendFrameworkOne::SEPARETOR |
| 97 | - . AbstractMaker::getClassName ( $dependence->getTable () ) |
|
| 97 | + . AbstractMaker::getClassName($dependence->getTable()) |
|
| 98 | 98 | . ZendFrameworkOne::SEPARETOR |
| 99 | 99 | . 'By' |
| 100 | 100 | . ZendFrameworkOne::SEPARETOR |
| 101 | - . $objColumn->getName (); |
|
| 101 | + . $objColumn->getName(); |
|
| 102 | 102 | |
| 103 | - if ( ! key_exists ( $name , $this->validFunc ) ) |
|
| 103 | + if ( ! key_exists($name, $this->validFunc)) |
|
| 104 | 104 | { |
| 105 | - $arrClass = array ( |
|
| 106 | - $makerFile->getConfig ()->createClassNamespace ( $dependence ), |
|
| 107 | - AbstractMaker::getClassName ( $dependence->getTable () ) |
|
| 105 | + $arrClass = array( |
|
| 106 | + $makerFile->getConfig()->createClassNamespace($dependence), |
|
| 107 | + AbstractMaker::getClassName($dependence->getTable()) |
|
| 108 | 108 | ); |
| 109 | - $class = implode ( ZendFrameworkOne::SEPARETOR , array_filter ( $arrClass ) ); |
|
| 109 | + $class = implode(ZendFrameworkOne::SEPARETOR, array_filter($arrClass)); |
|
| 110 | 110 | |
| 111 | - $this->validFunc[ $name ] = true; |
|
| 112 | - $depends[] = array ( |
|
| 111 | + $this->validFunc[$name] = true; |
|
| 112 | + $depends[] = array( |
|
| 113 | 113 | 'class' => $class, |
| 114 | - 'function' => AbstractMaker::getClassName ( $name ) , |
|
| 115 | - 'table' => $dependence->getTable () , |
|
| 116 | - 'column' => $dependence->getColumn () , |
|
| 117 | - 'name' => $dependence->getNameConstrant () |
|
| 114 | + 'function' => AbstractMaker::getClassName($name), |
|
| 115 | + 'table' => $dependence->getTable(), |
|
| 116 | + 'column' => $dependence->getColumn(), |
|
| 117 | + 'name' => $dependence->getNameConstrant() |
|
| 118 | 118 | ); |
| 119 | 119 | } |
| 120 | - unset( $name ); |
|
| 120 | + unset($name); |
|
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | |
@@ -28,67 +28,67 @@ |
||
| 28 | 28 | * |
| 29 | 29 | * @return array |
| 30 | 30 | */ |
| 31 | - public function parseRelation ( \Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable ) |
|
| 31 | + public function parseRelation(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable) |
|
| 32 | 32 | { |
| 33 | 33 | $referenceMap = ''; |
| 34 | - $references = array (); |
|
| 34 | + $references = array(); |
|
| 35 | 35 | $dependentTables = ''; |
| 36 | - $dependents = array (); |
|
| 37 | - foreach ( $dbTable->getForeingkeys () as $objColumn ) |
|
| 36 | + $dependents = array(); |
|
| 37 | + foreach ($dbTable->getForeingkeys() as $objColumn) |
|
| 38 | 38 | { |
| 39 | - $constrant = $objColumn->getFks (); |
|
| 39 | + $constrant = $objColumn->getFks(); |
|
| 40 | 40 | |
| 41 | - $arrClass = array ( |
|
| 42 | - $makerFile->getConfig ()->createClassNamespace ( $constrant ), |
|
| 41 | + $arrClass = array( |
|
| 42 | + $makerFile->getConfig()->createClassNamespace($constrant), |
|
| 43 | 43 | 'DbTable', |
| 44 | - AbstractMaker::getClassName ( $constrant->getTable () ) |
|
| 44 | + AbstractMaker::getClassName($constrant->getTable()) |
|
| 45 | 45 | ); |
| 46 | - $class = implode ( ZendFrameworkOne::SEPARETOR , array_filter ( $arrClass ) ); |
|
| 46 | + $class = implode(ZendFrameworkOne::SEPARETOR, array_filter($arrClass)); |
|
| 47 | 47 | |
| 48 | - $references[] = sprintf ( |
|
| 48 | + $references[] = sprintf( |
|
| 49 | 49 | " |
| 50 | 50 | '%s' => array ( |
| 51 | 51 | 'columns' => '%s' , |
| 52 | 52 | 'refTableClass' => '%s', |
| 53 | 53 | 'refColumns' =>'%s' |
| 54 | 54 | )", |
| 55 | - AbstractMaker::getClassName ( $constrant->getNameConstrant () ), |
|
| 56 | - $objColumn->getName (), |
|
| 55 | + AbstractMaker::getClassName($constrant->getNameConstrant()), |
|
| 56 | + $objColumn->getName(), |
|
| 57 | 57 | $class, |
| 58 | - $constrant->getColumn () |
|
| 58 | + $constrant->getColumn() |
|
| 59 | 59 | |
| 60 | 60 | ); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - if ( sizeof ( $references ) > 0 ) |
|
| 63 | + if (sizeof($references) > 0) |
|
| 64 | 64 | { |
| 65 | 65 | $referenceMap = "protected \$_referenceMap = array(" . |
| 66 | - join ( ',', $references ) . "\n );"; |
|
| 66 | + join(',', $references) . "\n );"; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - foreach ( $dbTable->getDependences () as $objColumn ) |
|
| 69 | + foreach ($dbTable->getDependences() as $objColumn) |
|
| 70 | 70 | { |
| 71 | - foreach ( $objColumn->getDependences () as $dependence ) |
|
| 71 | + foreach ($objColumn->getDependences() as $dependence) |
|
| 72 | 72 | { |
| 73 | - $arrClass = array ( |
|
| 74 | - $makerFile->getConfig ()->createClassNamespace ( $dependence ), |
|
| 73 | + $arrClass = array( |
|
| 74 | + $makerFile->getConfig()->createClassNamespace($dependence), |
|
| 75 | 75 | 'DbTable', |
| 76 | - AbstractMaker::getClassName ( $dependence->getTable () ) |
|
| 76 | + AbstractMaker::getClassName($dependence->getTable()) |
|
| 77 | 77 | ); |
| 78 | - $class = implode ( ZendFrameworkOne::SEPARETOR , array_filter ( $arrClass ) ); |
|
| 78 | + $class = implode(ZendFrameworkOne::SEPARETOR, array_filter($arrClass)); |
|
| 79 | 79 | |
| 80 | 80 | $dependents[] = $class; |
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - if ( sizeof ( $dependents ) > 0 ) |
|
| 84 | + if (sizeof($dependents) > 0) |
|
| 85 | 85 | { |
| 86 | 86 | $dependentTables = "protected \$_dependentTables = array(\n '" . |
| 87 | - join ( "',\n '", $dependents ) . "'\n );"; |
|
| 87 | + join("',\n '", $dependents) . "'\n );"; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | |
| 91 | - return array ( |
|
| 91 | + return array( |
|
| 92 | 92 | 'referenceMap' => $referenceMap, |
| 93 | 93 | 'dependentTables' => $dependentTables |
| 94 | 94 | ); |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | /** |
| 137 | 137 | * @param \Classes\Db\DbTable|\Classes\Db\Constrant $table |
| 138 | 138 | * |
| 139 | - * @return mixed |
|
| 139 | + * @return string |
|
| 140 | 140 | */ |
| 141 | 141 | |
| 142 | 142 | public function createClassNamespace ( $table ) |
@@ -225,6 +225,9 @@ discard block |
||
| 225 | 225 | return true; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | + /** |
|
| 229 | + * @return string |
|
| 230 | + */ |
|
| 228 | 231 | protected function getFrameworkIni () |
| 229 | 232 | { |
| 230 | 233 | return $this->framworkFiles[ 'ini' ]; |
@@ -332,7 +335,6 @@ discard block |
||
| 332 | 335 | } |
| 333 | 336 | |
| 334 | 337 | /** |
| 335 | - * @param string $schema |
|
| 336 | 338 | * |
| 337 | 339 | * @return string |
| 338 | 340 | */ |
@@ -134,8 +134,7 @@ |
||
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | |
| 137 | - } |
|
| 138 | - else { |
|
| 137 | + } else { |
|
| 139 | 138 | $url = array ( |
| 140 | 139 | $this->baseLocation, |
| 141 | 140 | $driverBase, |
@@ -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 | } |