@@ -3,19 +3,19 @@ |
||
| 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 <?=$this->config->namespace?>\Models |
| 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 | -namespace <?=$this->config->namespace?$this->config->namespace."\\":""?>Models; |
|
| 18 | +namespace <?=$this->config->namespace ? $this->config->namespace . "\\" : ""?>Models; |
|
| 19 | 19 | |
| 20 | 20 | abstract class AbstractPeer |
| 21 | 21 | { |
@@ -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 | |
@@ -174,10 +174,10 @@ discard block |
||
| 174 | 174 | $sqlTables = !empty($this->tablesName)?"AND table_name IN ( $this->tablesName )":''; |
| 175 | 175 | |
| 176 | 176 | $this->totalTables = $this->getPDO () |
| 177 | - ->query ( |
|
| 178 | - "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{$this->database}' $sqlTables" |
|
| 179 | - ) |
|
| 180 | - ->fetchColumn (); |
|
| 177 | + ->query ( |
|
| 178 | + "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{$this->database}' $sqlTables" |
|
| 179 | + ) |
|
| 180 | + ->fetchColumn (); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | return (int) $this->totalTables; |
@@ -194,10 +194,10 @@ discard block |
||
| 194 | 194 | public function getSequence ( $table, $column, $schema = 0 ) |
| 195 | 195 | { |
| 196 | 196 | $return = $this->getPDO () |
| 197 | - ->query ( |
|
| 198 | - "select * from information_schema.columns where extra like '%auto_increment%' and TABLE_SCHEMA='{$this->database}' AND TABLE_NAME='{$table}' AND COLUMN_NAME='{$column}';" |
|
| 199 | - ) |
|
| 200 | - ->fetch ( \PDO::FETCH_ASSOC ); |
|
| 197 | + ->query ( |
|
| 198 | + "select * from information_schema.columns where extra like '%auto_increment%' and TABLE_SCHEMA='{$this->database}' AND TABLE_NAME='{$table}' AND COLUMN_NAME='{$column}';" |
|
| 199 | + ) |
|
| 200 | + ->fetch ( \PDO::FETCH_ASSOC ); |
|
| 201 | 201 | |
| 202 | 202 | if ( !$return ) { |
| 203 | 203 | 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,12 +112,12 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | * @return array[] |
| 114 | 114 | */ |
| 115 | - public function getListColumns () |
|
| 115 | + public function getListColumns() |
|
| 116 | 116 | { |
| 117 | - $sqlTables = !empty($this->tablesName)?"AND table_name IN ( $this->tablesName )":''; |
|
| 117 | + $sqlTables = ! empty($this->tablesName) ? "AND table_name IN ( $this->tablesName )" : ''; |
|
| 118 | 118 | |
| 119 | - return $this->getPDO () |
|
| 120 | - ->query ( |
|
| 119 | + return $this->getPDO() |
|
| 120 | + ->query( |
|
| 121 | 121 | "select |
| 122 | 122 | 0 AS table_schema, |
| 123 | 123 | table_name, |
@@ -129,18 +129,18 @@ discard block |
||
| 129 | 129 | where table_schema IN ('{$this->database}') $sqlTables |
| 130 | 130 | order by table_name,ordinal_position" |
| 131 | 131 | ) |
| 132 | - ->fetchAll ( \PDO::FETCH_ASSOC ); |
|
| 132 | + ->fetchAll(\PDO::FETCH_ASSOC); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
| 136 | 136 | * @return array |
| 137 | 137 | */ |
| 138 | - public function getListConstrant () |
|
| 138 | + public function getListConstrant() |
|
| 139 | 139 | { |
| 140 | - $sqlTables = !empty($this->tablesName)?"AND k.table_name IN ( $this->tablesName )":''; |
|
| 140 | + $sqlTables = ! empty($this->tablesName) ? "AND k.table_name IN ( $this->tablesName )" : ''; |
|
| 141 | 141 | |
| 142 | - $objQuery = $this->getPDO () |
|
| 143 | - ->query ( |
|
| 142 | + $objQuery = $this->getPDO() |
|
| 143 | + ->query( |
|
| 144 | 144 | "SELECT distinct |
| 145 | 145 | i.constraint_type, |
| 146 | 146 | k.constraint_name, |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | i.TABLE_SCHEMA IN ('{$this->database}') AND i.CONSTRAINT_TYPE IN ('FOREIGN KEY', 'PRIMARY KEY' ) $sqlTables |
| 160 | 160 | order by k.table_schema, k.table_name;" |
| 161 | 161 | ); |
| 162 | - return $objQuery?$objQuery->fetchAll ( \PDO::FETCH_ASSOC ):array(); |
|
| 162 | + return $objQuery ? $objQuery->fetchAll(\PDO::FETCH_ASSOC) : array(); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -167,17 +167,17 @@ discard block |
||
| 167 | 167 | * |
| 168 | 168 | * @return int |
| 169 | 169 | */ |
| 170 | - public function getTotalTables () |
|
| 170 | + public function getTotalTables() |
|
| 171 | 171 | { |
| 172 | - if ( empty( $this->totalTables ) ) { |
|
| 172 | + if (empty($this->totalTables)) { |
|
| 173 | 173 | |
| 174 | - $sqlTables = !empty($this->tablesName)?"AND table_name IN ( $this->tablesName )":''; |
|
| 174 | + $sqlTables = ! empty($this->tablesName) ? "AND table_name IN ( $this->tablesName )" : ''; |
|
| 175 | 175 | |
| 176 | - $this->totalTables = $this->getPDO () |
|
| 177 | - ->query ( |
|
| 176 | + $this->totalTables = $this->getPDO() |
|
| 177 | + ->query( |
|
| 178 | 178 | "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{$this->database}' $sqlTables" |
| 179 | 179 | ) |
| 180 | - ->fetchColumn (); |
|
| 180 | + ->fetchColumn(); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | return (int) $this->totalTables; |
@@ -191,15 +191,15 @@ discard block |
||
| 191 | 191 | * |
| 192 | 192 | * @return string |
| 193 | 193 | */ |
| 194 | - public function getSequence ( $table, $column, $schema = 0 ) |
|
| 194 | + public function getSequence($table, $column, $schema = 0) |
|
| 195 | 195 | { |
| 196 | - $return = $this->getPDO () |
|
| 197 | - ->query ( |
|
| 196 | + $return = $this->getPDO() |
|
| 197 | + ->query( |
|
| 198 | 198 | "select * from information_schema.columns where extra like '%auto_increment%' and TABLE_SCHEMA='{$this->database}' AND TABLE_NAME='{$table}' AND COLUMN_NAME='{$column}';" |
| 199 | 199 | ) |
| 200 | - ->fetch ( \PDO::FETCH_ASSOC ); |
|
| 200 | + ->fetch(\PDO::FETCH_ASSOC); |
|
| 201 | 201 | |
| 202 | - if ( !$return ) { |
|
| 202 | + if ( ! $return) { |
|
| 203 | 203 | return; |
| 204 | 204 | } |
| 205 | 205 | |
@@ -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 | |
@@ -99,6 +99,7 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * Analisa os caminhos das pastas base |
| 102 | + * @param string $basePath |
|
| 102 | 103 | */ |
| 103 | 104 | public function parseLocation ( $basePath ) |
| 104 | 105 | { |
@@ -227,6 +228,9 @@ discard block |
||
| 227 | 228 | echo "\n\033[1;32mSuccessfully process finished!\n\033[0m"; |
| 228 | 229 | } |
| 229 | 230 | |
| 231 | + /** |
|
| 232 | + * @param integer $cur |
|
| 233 | + */ |
|
| 230 | 234 | private function waitOfDatabase ( &$cur ) |
| 231 | 235 | { |
| 232 | 236 | printf ( "\033[1;33mWait, the database is being analyzed..\033[0m\n" ); |
@@ -293,6 +297,7 @@ discard block |
||
| 293 | 297 | * parse a tpl file and return the result |
| 294 | 298 | * |
| 295 | 299 | * @param String $tplFile |
| 300 | + * @param AbstractAdapter $objMakeFile |
|
| 296 | 301 | * |
| 297 | 302 | * @return String |
| 298 | 303 | */ |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | foreach ( $arrFoldersName as $index => $folderName ) |
| 101 | 101 | { |
| 102 | 102 | $arrFoldersName[ $index ] = $this->getConfig () |
| 103 | - ->replaceReservedWord ( $folderName ); |
|
| 103 | + ->replaceReservedWord ( $folderName ); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | return implode ( DIRECTORY_SEPARATOR , array_filter ( $arrFoldersName ) ); |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | $folderName , |
| 158 | 158 | $this->getClassName ( |
| 159 | 159 | $this->getConfig () |
| 160 | - ->getDatabase () |
|
| 160 | + ->getDatabase () |
|
| 161 | 161 | ) |
| 162 | 162 | ); |
| 163 | 163 | $this->location = array ( $this->filterLocation ( $url ) ); |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | /** |
| 23 | 23 | * @type string[] |
| 24 | 24 | */ |
| 25 | - public $location = array (); |
|
| 25 | + public $location = array(); |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * caminho de pastas Base |
@@ -46,46 +46,46 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | private $msgReservedWord = "\033[0mPlease enter the value for reserved word \033[0;31m'%index%' \033[1;33m[%config%]:\033[0m "; |
| 48 | 48 | |
| 49 | - public function __construct ( Config $config ) |
|
| 49 | + public function __construct(Config $config) |
|
| 50 | 50 | { |
| 51 | - $this->config = $config->getAdapterConfig (); |
|
| 52 | - $this->parseReservedWord ( $this->getConfig () ); |
|
| 53 | - $this->driver = $config->getAdapterDriver ( $this->getConfig () ); |
|
| 54 | - $this->parseLocation ( $config->_basePath ); |
|
| 51 | + $this->config = $config->getAdapterConfig(); |
|
| 52 | + $this->parseReservedWord($this->getConfig()); |
|
| 53 | + $this->driver = $config->getAdapterDriver($this->getConfig()); |
|
| 54 | + $this->parseLocation($config->_basePath); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * @param AdapterConfig\AbstractAdapter $config |
| 59 | 59 | */ |
| 60 | - public function parseReservedWord ( AdapterConfig\AbstractAdapter $config ) |
|
| 60 | + public function parseReservedWord(AdapterConfig\AbstractAdapter $config) |
|
| 61 | 61 | { |
| 62 | 62 | $palavrasReservadas = $config->reservedWord; |
| 63 | - if ( ! $palavrasReservadas ) |
|
| 63 | + if ( ! $palavrasReservadas) |
|
| 64 | 64 | { |
| 65 | 65 | return; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - $schema = $config->getSchemas (); |
|
| 69 | - $db = $config->getDatabase (); |
|
| 70 | - $hasSchema = array_intersect ( $schema , array_flip ( $palavrasReservadas ) ); |
|
| 71 | - $hasDatabase = in_array ( $db , $palavrasReservadas ); |
|
| 72 | - if ( ! ( $hasSchema or $hasDatabase ) ) |
|
| 68 | + $schema = $config->getSchemas(); |
|
| 69 | + $db = $config->getDatabase(); |
|
| 70 | + $hasSchema = array_intersect($schema, array_flip($palavrasReservadas)); |
|
| 71 | + $hasDatabase = in_array($db, $palavrasReservadas); |
|
| 72 | + if ( ! ($hasSchema or $hasDatabase)) |
|
| 73 | 73 | { |
| 74 | 74 | return; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | echo "- database has reserved words\n"; |
| 78 | - foreach ( $palavrasReservadas as $index => $config ) |
|
| 78 | + foreach ($palavrasReservadas as $index => $config) |
|
| 79 | 79 | { |
| 80 | - $attribs = array ( |
|
| 81 | - "%index%" => $index , |
|
| 80 | + $attribs = array( |
|
| 81 | + "%index%" => $index, |
|
| 82 | 82 | "%config%" => $config |
| 83 | 83 | ); |
| 84 | - echo strtr ( $this->msgReservedWord , $attribs ); |
|
| 85 | - $line = trim ( fgets ( STDIN ) ); |
|
| 86 | - if ( ! empty( $line ) ) |
|
| 84 | + echo strtr($this->msgReservedWord, $attribs); |
|
| 85 | + $line = trim(fgets(STDIN)); |
|
| 86 | + if ( ! empty($line)) |
|
| 87 | 87 | { |
| 88 | - $this->getConfig ()->reservedWord[ $index ] = $line; |
|
| 88 | + $this->getConfig()->reservedWord[$index] = $line; |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | } |
@@ -95,199 +95,199 @@ discard block |
||
| 95 | 95 | * |
| 96 | 96 | * @return string |
| 97 | 97 | */ |
| 98 | - private function filterLocation ( $arrFoldersName ) |
|
| 98 | + private function filterLocation($arrFoldersName) |
|
| 99 | 99 | { |
| 100 | - foreach ( $arrFoldersName as $index => $folderName ) |
|
| 100 | + foreach ($arrFoldersName as $index => $folderName) |
|
| 101 | 101 | { |
| 102 | - $arrFoldersName[ $index ] = $this->getConfig () |
|
| 103 | - ->replaceReservedWord ( $folderName ); |
|
| 102 | + $arrFoldersName[$index] = $this->getConfig() |
|
| 103 | + ->replaceReservedWord($folderName); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - return implode ( DIRECTORY_SEPARATOR , array_filter ( $arrFoldersName ) ); |
|
| 106 | + return implode(DIRECTORY_SEPARATOR, array_filter($arrFoldersName)); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | 110 | * Analisa os caminhos das pastas base |
| 111 | 111 | */ |
| 112 | - public function parseLocation ( $basePath ) |
|
| 112 | + public function parseLocation($basePath) |
|
| 113 | 113 | { |
| 114 | 114 | |
| 115 | - $arrBase = array ( |
|
| 116 | - $basePath , |
|
| 115 | + $arrBase = array( |
|
| 116 | + $basePath, |
|
| 117 | 117 | $this->config->path |
| 118 | 118 | ); |
| 119 | 119 | |
| 120 | - $this->baseLocation = $this->filterLocation ( $arrBase ); |
|
| 120 | + $this->baseLocation = $this->filterLocation($arrBase); |
|
| 121 | 121 | |
| 122 | 122 | # pasta com nome do driver do banco |
| 123 | 123 | $driverBase = ''; |
| 124 | - if ( (bool) @$this->config->{"folder-database"} ) |
|
| 124 | + if ((bool) @$this->config->{"folder-database"} ) |
|
| 125 | 125 | { |
| 126 | - $classDriver = explode ( '\\' , get_class ( $this->driver ) ); |
|
| 127 | - $driverBase = end ( $classDriver ); |
|
| 126 | + $classDriver = explode('\\', get_class($this->driver)); |
|
| 127 | + $driverBase = end($classDriver); |
|
| 128 | 128 | } |
| 129 | 129 | $folderName = ''; |
| 130 | - if ( (bool) @$this->config->{"folder-name"} ) |
|
| 130 | + if ((bool) @$this->config->{"folder-name"} ) |
|
| 131 | 131 | { |
| 132 | - $folderName = $this->getClassName ( trim ( $this->config->{"folder-name"} ) ); |
|
| 132 | + $folderName = $this->getClassName(trim($this->config->{"folder-name"} )); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - if ( $this->config->hasSchemas () ) |
|
| 135 | + if ($this->config->hasSchemas()) |
|
| 136 | 136 | { |
| 137 | 137 | |
| 138 | - $schemas = $this->config->getSchemas (); |
|
| 139 | - foreach ( $schemas as $schema ) |
|
| 138 | + $schemas = $this->config->getSchemas(); |
|
| 139 | + foreach ($schemas as $schema) |
|
| 140 | 140 | { |
| 141 | - $arrUrl = array ( |
|
| 142 | - $this->baseLocation , |
|
| 143 | - $driverBase , |
|
| 144 | - $folderName , |
|
| 145 | - $this->getClassName ( $schema ) |
|
| 141 | + $arrUrl = array( |
|
| 142 | + $this->baseLocation, |
|
| 143 | + $driverBase, |
|
| 144 | + $folderName, |
|
| 145 | + $this->getClassName($schema) |
|
| 146 | 146 | ); |
| 147 | 147 | |
| 148 | - $this->location[ $schema ] = $this->filterLocation ( $arrUrl ); |
|
| 149 | - unset( $arrUrl ); |
|
| 148 | + $this->location[$schema] = $this->filterLocation($arrUrl); |
|
| 149 | + unset($arrUrl); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | } else |
| 153 | 153 | { |
| 154 | - $url = array ( |
|
| 155 | - $this->baseLocation , |
|
| 156 | - $driverBase , |
|
| 157 | - $folderName , |
|
| 158 | - $this->getClassName ( |
|
| 159 | - $this->getConfig () |
|
| 160 | - ->getDatabase () |
|
| 154 | + $url = array( |
|
| 155 | + $this->baseLocation, |
|
| 156 | + $driverBase, |
|
| 157 | + $folderName, |
|
| 158 | + $this->getClassName( |
|
| 159 | + $this->getConfig() |
|
| 160 | + ->getDatabase() |
|
| 161 | 161 | ) |
| 162 | 162 | ); |
| 163 | - $this->location = array ( $this->filterLocation ( $url ) ); |
|
| 164 | - unset( $url ); |
|
| 163 | + $this->location = array($this->filterLocation($url)); |
|
| 164 | + unset($url); |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
| 169 | 169 | * @return AdapterConfig\AbstractAdapter |
| 170 | 170 | */ |
| 171 | - public function getConfig () |
|
| 171 | + public function getConfig() |
|
| 172 | 172 | { |
| 173 | 173 | return $this->config; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /* Get current time */ |
| 177 | - public function startTime () |
|
| 177 | + public function startTime() |
|
| 178 | 178 | { |
| 179 | 179 | echo "\033[1;32mStarting..\033[0m\n"; |
| 180 | - $this->startTime = microtime ( true ); |
|
| 180 | + $this->startTime = microtime(true); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - private function getRunTime () |
|
| 183 | + private function getRunTime() |
|
| 184 | 184 | { |
| 185 | - return round ( ( microtime ( true ) - $this->startTime ) , 3 ); |
|
| 185 | + return round((microtime(true) - $this->startTime), 3); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
| 189 | 189 | * @param $objMakeFile |
| 190 | 190 | */ |
| 191 | - private function generateFilesFixed ( FilesFixeds $objFilesFixeds ) |
|
| 191 | + private function generateFilesFixed(FilesFixeds $objFilesFixeds) |
|
| 192 | 192 | { |
| 193 | - if ( $objFilesFixeds->hasData () ) |
|
| 193 | + if ($objFilesFixeds->hasData()) |
|
| 194 | 194 | { |
| 195 | 195 | $file = $this->baseLocation |
| 196 | 196 | . DIRECTORY_SEPARATOR |
| 197 | - . $objFilesFixeds->getFileName () |
|
| 197 | + . $objFilesFixeds->getFileName() |
|
| 198 | 198 | . '.php'; |
| 199 | 199 | |
| 200 | - $tpl = $this->getParsedTplContents ( $objFilesFixeds->getTpl () ); |
|
| 201 | - self::makeSourcer ( $file , $tpl , true ); |
|
| 200 | + $tpl = $this->getParsedTplContents($objFilesFixeds->getTpl()); |
|
| 201 | + self::makeSourcer($file, $tpl, true); |
|
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
| 206 | 206 | * Executa o Make, criando arquivos e Diretorios |
| 207 | 207 | */ |
| 208 | - public function run () |
|
| 208 | + public function run() |
|
| 209 | 209 | { |
| 210 | 210 | $cur = 0; |
| 211 | 211 | $numFilesCreated = 0; |
| 212 | 212 | $numFilesIgnored = 0; |
| 213 | 213 | |
| 214 | - $this->startTime (); |
|
| 215 | - $this->waitOfDatabase ( $cur ); |
|
| 214 | + $this->startTime(); |
|
| 215 | + $this->waitOfDatabase($cur); |
|
| 216 | 216 | |
| 217 | - $this->max = $this->driver->getTotalTables () * $this->countDiretory (); |
|
| 218 | - $progressBar = ProgressBar::getInstance ()->setMaxByte ( $this->max ); |
|
| 217 | + $this->max = $this->driver->getTotalTables() * $this->countDiretory(); |
|
| 218 | + $progressBar = ProgressBar::getInstance()->setMaxByte($this->max); |
|
| 219 | 219 | |
| 220 | - foreach ( $this->location as $schema => $location ) |
|
| 220 | + foreach ($this->location as $schema => $location) |
|
| 221 | 221 | { |
| 222 | - foreach ( $this->factoryMakerFile () as $objMakeFile ) |
|
| 222 | + foreach ($this->factoryMakerFile() as $objMakeFile) |
|
| 223 | 223 | { |
| 224 | - $path = $location . DIRECTORY_SEPARATOR . $objMakeFile->getPastName (); |
|
| 225 | - if ( $this->config->isCleanTrash () ) |
|
| 224 | + $path = $location . DIRECTORY_SEPARATOR . $objMakeFile->getPastName(); |
|
| 225 | + if ($this->config->isCleanTrash()) |
|
| 226 | 226 | { |
| 227 | - CleanTrash::getInstance ()->run ( $path , $this->driver , $schema ); |
|
| 227 | + CleanTrash::getInstance()->run($path, $this->driver, $schema); |
|
| 228 | 228 | } |
| 229 | - self::makeDir ( $path ); |
|
| 229 | + self::makeDir($path); |
|
| 230 | 230 | |
| 231 | 231 | #Cria as Classes de Exceção e Abstratas |
| 232 | - foreach ( $objMakeFile->getListFilesFixed () as $nameObject ) |
|
| 232 | + foreach ($objMakeFile->getListFilesFixed() as $nameObject) |
|
| 233 | 233 | { |
| 234 | - $this->generateFilesFixed ( $objMakeFile->getFilesFixeds ( $nameObject ) ); |
|
| 234 | + $this->generateFilesFixed($objMakeFile->getFilesFixeds($nameObject)); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | #Cria as Classes do Banco |
| 238 | - foreach ( $this->driver->getTables ( $schema ) as $key => $objTables ) |
|
| 238 | + foreach ($this->driver->getTables($schema) as $key => $objTables) |
|
| 239 | 239 | { |
| 240 | 240 | $file = $path . DIRECTORY_SEPARATOR |
| 241 | - . self::getClassName ( $objTables->getName () ) . '.php'; |
|
| 241 | + . self::getClassName($objTables->getName()) . '.php'; |
|
| 242 | 242 | |
| 243 | - $tpl = $this->getParsedTplContents ( |
|
| 244 | - $objMakeFile->getFileTpl () , |
|
| 245 | - $objMakeFile->parseRelation ( $this , $objTables ) , |
|
| 246 | - $objTables , |
|
| 243 | + $tpl = $this->getParsedTplContents( |
|
| 244 | + $objMakeFile->getFileTpl(), |
|
| 245 | + $objMakeFile->parseRelation($this, $objTables), |
|
| 246 | + $objTables, |
|
| 247 | 247 | $objMakeFile |
| 248 | 248 | |
| 249 | 249 | ); |
| 250 | - if ( self::makeSourcer ( $file , $tpl , $objMakeFile->isOverwrite () ) ) |
|
| 250 | + if (self::makeSourcer($file, $tpl, $objMakeFile->isOverwrite())) |
|
| 251 | 251 | { |
| 252 | - ++ $numFilesCreated; |
|
| 252 | + ++$numFilesCreated; |
|
| 253 | 253 | } else |
| 254 | 254 | { |
| 255 | - ++ $numFilesIgnored; |
|
| 255 | + ++$numFilesIgnored; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | ++$cur; |
| 259 | - $progressBar->setProgress ( $cur )->render(); |
|
| 259 | + $progressBar->setProgress($cur)->render(); |
|
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - $this->reportProcess ( $numFilesCreated , $numFilesIgnored ); |
|
| 264 | + $this->reportProcess($numFilesCreated, $numFilesIgnored); |
|
| 265 | 265 | $progressBar->finish(); |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - private function waitOfDatabase ( &$cur ) |
|
| 268 | + private function waitOfDatabase(&$cur) |
|
| 269 | 269 | { |
| 270 | - printf ( "\033[1;33mWait, the database is being analyzed..\033[0m\n" ); |
|
| 271 | - $this->driver->runDatabase (); |
|
| 270 | + printf("\033[1;33mWait, the database is being analyzed..\033[0m\n"); |
|
| 271 | + $this->driver->runDatabase(); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - private function reportProcess ( $numFilesCreated = 0 , $numFilesIgnored = 0 ) |
|
| 274 | + private function reportProcess($numFilesCreated = 0, $numFilesIgnored = 0) |
|
| 275 | 275 | { |
| 276 | - if ( $this->config->isStatusEnabled () ) |
|
| 276 | + if ($this->config->isStatusEnabled()) |
|
| 277 | 277 | { |
| 278 | - $databases = count ( $this->location ); |
|
| 279 | - $countDir = $this->countDiretory (); |
|
| 280 | - $totalTable = $this->driver->getTotalTables (); |
|
| 278 | + $databases = count($this->location); |
|
| 279 | + $countDir = $this->countDiretory(); |
|
| 280 | + $totalTable = $this->driver->getTotalTables(); |
|
| 281 | 281 | $totalFiles = $numFilesIgnored + $numFilesCreated; |
| 282 | - $totalFilesDeleted = CleanTrash::getInstance ()->getNumFilesDeleted (); |
|
| 282 | + $totalFilesDeleted = CleanTrash::getInstance()->getNumFilesDeleted(); |
|
| 283 | 283 | echo "\n------"; |
| 284 | - printf ( "\n\r-Files generated/updated: \033[1;33m%s\033[0m" , $numFilesCreated ); |
|
| 285 | - printf ( "\n\r-Files not upgradeable: \033[1;33m%s\033[0m" , $numFilesIgnored ); |
|
| 286 | - printf ( "\n\r-Files deleted: \033[1;33m%s\033[0m" , $totalFilesDeleted ); |
|
| 287 | - printf ( "\n\r-Total files analyzed: \033[1;33m%s of %s\033[0m" , $totalFiles , $this->max ); |
|
| 288 | - printf ( "\n\r-Diretories: \033[1;33m%s\033[0m" , $databases * $countDir ); |
|
| 289 | - printf ( "\n\r-Scanned tables: \033[1;33m%s\033[0m" , $totalTable ); |
|
| 290 | - printf ( "\n\r-Execution time: \033[1;33m%ssec\033[0m" , $this->getRunTime () ); |
|
| 284 | + printf("\n\r-Files generated/updated: \033[1;33m%s\033[0m", $numFilesCreated); |
|
| 285 | + printf("\n\r-Files not upgradeable: \033[1;33m%s\033[0m", $numFilesIgnored); |
|
| 286 | + printf("\n\r-Files deleted: \033[1;33m%s\033[0m", $totalFilesDeleted); |
|
| 287 | + printf("\n\r-Total files analyzed: \033[1;33m%s of %s\033[0m", $totalFiles, $this->max); |
|
| 288 | + printf("\n\r-Diretories: \033[1;33m%s\033[0m", $databases * $countDir); |
|
| 289 | + printf("\n\r-Scanned tables: \033[1;33m%s\033[0m", $totalTable); |
|
| 290 | + printf("\n\r-Execution time: \033[1;33m%ssec\033[0m", $this->getRunTime()); |
|
| 291 | 291 | echo "\n------"; |
| 292 | 292 | } |
| 293 | 293 | } |
@@ -297,9 +297,9 @@ discard block |
||
| 297 | 297 | * |
| 298 | 298 | * @return AbstractAdapter[] |
| 299 | 299 | */ |
| 300 | - public function factoryMakerFile () |
|
| 300 | + public function factoryMakerFile() |
|
| 301 | 301 | { |
| 302 | - return $this->config->getMakeFileInstances (); |
|
| 302 | + return $this->config->getMakeFileInstances(); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
@@ -307,16 +307,16 @@ discard block |
||
| 307 | 307 | * |
| 308 | 308 | * @return int |
| 309 | 309 | */ |
| 310 | - public function countDiretory () |
|
| 310 | + public function countDiretory() |
|
| 311 | 311 | { |
| 312 | - if ( null === $this->countDir ) |
|
| 312 | + if (null === $this->countDir) |
|
| 313 | 313 | { |
| 314 | 314 | $this->countDir = 1; |
| 315 | - foreach ( $this->factoryMakerFile () as $abstractAdapter ) |
|
| 315 | + foreach ($this->factoryMakerFile() as $abstractAdapter) |
|
| 316 | 316 | { |
| 317 | - if ( $abstractAdapter->hasDiretory () ) |
|
| 317 | + if ($abstractAdapter->hasDiretory()) |
|
| 318 | 318 | { |
| 319 | - ++ $this->countDir; |
|
| 319 | + ++$this->countDir; |
|
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | 322 | } |
@@ -332,25 +332,25 @@ discard block |
||
| 332 | 332 | * |
| 333 | 333 | * @return String |
| 334 | 334 | */ |
| 335 | - protected function getParsedTplContents ( |
|
| 336 | - $tplFile , $vars = array () , \Classes\Db\DbTable $objTables = null , |
|
| 335 | + protected function getParsedTplContents( |
|
| 336 | + $tplFile, $vars = array(), \Classes\Db\DbTable $objTables = null, |
|
| 337 | 337 | $objMakeFile = null |
| 338 | - ){ |
|
| 338 | + ) { |
|
| 339 | 339 | |
| 340 | - $arrUrl = array ( |
|
| 341 | - __DIR__ , |
|
| 342 | - 'templates' , |
|
| 343 | - $this->config->framework , |
|
| 340 | + $arrUrl = array( |
|
| 341 | + __DIR__, |
|
| 342 | + 'templates', |
|
| 343 | + $this->config->framework, |
|
| 344 | 344 | $tplFile |
| 345 | 345 | ); |
| 346 | 346 | |
| 347 | - $filePath = implode ( DIRECTORY_SEPARATOR , filter_var_array ( $arrUrl ) ); |
|
| 347 | + $filePath = implode(DIRECTORY_SEPARATOR, filter_var_array($arrUrl)); |
|
| 348 | 348 | |
| 349 | - extract ( $vars ); |
|
| 350 | - ob_start (); |
|
| 349 | + extract($vars); |
|
| 350 | + ob_start(); |
|
| 351 | 351 | require $filePath; |
| 352 | - $data = ob_get_contents (); |
|
| 353 | - ob_end_clean (); |
|
| 352 | + $data = ob_get_contents(); |
|
| 353 | + ob_end_clean(); |
|
| 354 | 354 | |
| 355 | 355 | return $data; |
| 356 | 356 | } |
@@ -3,20 +3,20 @@ |
||
| 3 | 3 | /** |
| 4 | 4 | * Data Entity implementation for this class |
| 5 | 5 | * |
| 6 | - * <?=$this->config->last_modify."\n"?> |
|
| 6 | + * <?=$this->config->last_modify . "\n"?> |
|
| 7 | 7 | * |
| 8 | - * @package <?=$objTables->getNamespace()."\n"?> |
|
| 9 | - * @see <?=$objTables->getNamespace()?>_Entity_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?>. <?="\n"?> |
|
| 8 | + * @package <?=$objTables->getNamespace() . "\n"?> |
|
| 9 | + * @see <?=$objTables->getNamespace()?>_Entity_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?>. <?="\n"?> |
|
| 10 | 10 | * |
| 11 | - * @author <?=$this->config->author."\n"?> |
|
| 11 | + * @author <?=$this->config->author . "\n"?> |
|
| 12 | 12 | * |
| 13 | - * @copyright <?=$this->config->copyright."\n"?> |
|
| 14 | - * @license <?=$this->config->license."\n"?> |
|
| 15 | - * @link <?=$this->config->link."\n"?> |
|
| 16 | - * @version <?=$this->config->version."\n"?> |
|
| 13 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
| 14 | + * @license <?=$this->config->license . "\n"?> |
|
| 15 | + * @link <?=$this->config->link . "\n"?> |
|
| 16 | + * @version <?=$this->config->version . "\n"?> |
|
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | -class <?=$objTables->getNamespace()?>_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?> extends <?=$objTables->getNamespace()?>_Entity_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () ). "\n"?> |
|
| 19 | +class <?=$objTables->getNamespace()?>_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?> extends <?=$objTables->getNamespace()?>_Entity_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName()) . "\n"?> |
|
| 20 | 20 | { |
| 21 | 21 | /* @TODO Codifique aqui */ |
| 22 | 22 | } |
@@ -79,8 +79,7 @@ |
||
| 79 | 79 | $arg = getopt ( null, $arrValid ); |
| 80 | 80 | if ( array_key_exists ( 'init', $arg ) ) { |
| 81 | 81 | $maker = new \Classes\MakerConfigFile( $arg, $_path ); |
| 82 | - } |
|
| 83 | - else { |
|
| 82 | + } else { |
|
| 84 | 83 | $maker = new \Classes\MakerFile( new \Classes\Config( $arg, $_path, count ( $argv ) ) ); |
| 85 | 84 | } |
| 86 | 85 | |
@@ -1,22 +1,22 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! ini_get ( 'short_open_tag' ) ) |
|
| 3 | +if ( ! ini_get('short_open_tag')) |
|
| 4 | 4 | { |
| 5 | - die( "\033[0;31mError: please enable short_open_tag directive in php.ini\033[0m\n" ); |
|
| 5 | + die("\033[0;31mError: please enable short_open_tag directive in php.ini\033[0m\n"); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | -if ( ! ini_get ( 'register_argc_argv' ) ) |
|
| 8 | +if ( ! ini_get('register_argc_argv')) |
|
| 9 | 9 | { |
| 10 | - die( "\033[0;31mError: please enable register_argc_argv directive in php.ini\033[0m\n" ); |
|
| 10 | + die("\033[0;31mError: please enable register_argc_argv directive in php.ini\033[0m\n"); |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | -if ( function_exists ( 'ini_set' ) ) { |
|
| 14 | - @ini_set ( 'display_errors', 1 ); |
|
| 13 | +if (function_exists('ini_set')) { |
|
| 14 | + @ini_set('display_errors', 1); |
|
| 15 | 15 | |
| 16 | - $memoryInBytes = function ( $value ) { |
|
| 17 | - $unit = strtolower ( substr ( $value, -1, 1 ) ); |
|
| 16 | + $memoryInBytes = function($value) { |
|
| 17 | + $unit = strtolower(substr($value, -1, 1)); |
|
| 18 | 18 | $value = (int) $value; |
| 19 | - switch ( $unit ) { |
|
| 19 | + switch ($unit) { |
|
| 20 | 20 | case 'g': |
| 21 | 21 | $value *= 1024; |
| 22 | 22 | // no break (cumulative multiplier) |
@@ -30,22 +30,22 @@ discard block |
||
| 30 | 30 | return $value; |
| 31 | 31 | }; |
| 32 | 32 | |
| 33 | - $memoryLimit = trim ( ini_get ( 'memory_limit' ) ); |
|
| 33 | + $memoryLimit = trim(ini_get('memory_limit')); |
|
| 34 | 34 | // Increase memory_limit if it is lower than 1GB |
| 35 | - if ( $memoryLimit != -1 && $memoryInBytes( $memoryLimit ) < 1024 * 1024 * 1024 ) { |
|
| 36 | - @ini_set ( 'memory_limit', '1G' ); |
|
| 35 | + if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1024) { |
|
| 36 | + @ini_set('memory_limit', '1G'); |
|
| 37 | 37 | } |
| 38 | - unset( $memoryInBytes, $memoryLimit ); |
|
| 38 | + unset($memoryInBytes, $memoryLimit); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | -\Phar::interceptFileFuncs (); |
|
| 41 | +\Phar::interceptFileFuncs(); |
|
| 42 | 42 | |
| 43 | -set_include_path ( |
|
| 44 | - implode ( |
|
| 43 | +set_include_path( |
|
| 44 | + implode( |
|
| 45 | 45 | PATH_SEPARATOR, |
| 46 | - array ( |
|
| 47 | - realpath ( __DIR__ ), |
|
| 48 | - get_include_path (), |
|
| 46 | + array( |
|
| 47 | + realpath(__DIR__), |
|
| 48 | + get_include_path(), |
|
| 49 | 49 | ) |
| 50 | 50 | ) |
| 51 | 51 | ); |
@@ -55,15 +55,15 @@ discard block |
||
| 55 | 55 | require_once 'Classes/MakerConfigFile.php'; |
| 56 | 56 | |
| 57 | 57 | try { |
| 58 | - $_path = realpath ( |
|
| 59 | - str_replace ( |
|
| 58 | + $_path = realpath( |
|
| 59 | + str_replace( |
|
| 60 | 60 | 'phar://', |
| 61 | 61 | '', |
| 62 | 62 | __DIR__ |
| 63 | 63 | ) |
| 64 | 64 | ); |
| 65 | 65 | |
| 66 | - $arrValid = array ( |
|
| 66 | + $arrValid = array( |
|
| 67 | 67 | 'version', |
| 68 | 68 | 'help', |
| 69 | 69 | 'status', |
@@ -79,18 +79,18 @@ discard block |
||
| 79 | 79 | 'clean-trash:' |
| 80 | 80 | ); |
| 81 | 81 | |
| 82 | - $arg = getopt ( null, $arrValid ); |
|
| 83 | - if ( array_key_exists ( 'init', $arg ) ) { |
|
| 84 | - $maker = new \Classes\MakerConfigFile( $arg, dirname($_path) ); |
|
| 82 | + $arg = getopt(null, $arrValid); |
|
| 83 | + if (array_key_exists('init', $arg)) { |
|
| 84 | + $maker = new \Classes\MakerConfigFile($arg, dirname($_path)); |
|
| 85 | 85 | } |
| 86 | 86 | else { |
| 87 | - $maker = new \Classes\MakerFile( new \Classes\Config( $arg, dirname($_path), count ( $argv ) ) ); |
|
| 87 | + $maker = new \Classes\MakerFile(new \Classes\Config($arg, dirname($_path), count($argv))); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - $maker->run (); |
|
| 90 | + $maker->run(); |
|
| 91 | 91 | |
| 92 | -} catch ( \Exception $e ) { |
|
| 93 | - die( $e->getMessage () ); |
|
| 92 | +} catch (\Exception $e) { |
|
| 93 | + die($e->getMessage()); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | __halt_compiler(); |
| 97 | 97 | \ No newline at end of file |
@@ -34,6 +34,9 @@ |
||
| 34 | 34 | return self::$instance; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | + /** |
|
| 38 | + * @param string $directory |
|
| 39 | + */ |
|
| 37 | 40 | private function scanDir ( $directory ) |
| 38 | 41 | { |
| 39 | 42 | if(!is_dir($directory)){ |
@@ -17,16 +17,16 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * @type int |
| 19 | 19 | */ |
| 20 | - private $countFileDeleted=0; |
|
| 20 | + private $countFileDeleted = 0; |
|
| 21 | 21 | |
| 22 | - final private function __construct (){ } |
|
| 22 | + final private function __construct() { } |
|
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * @return \Classes\CleanTrash |
| 26 | 26 | */ |
| 27 | - public static function getInstance () |
|
| 27 | + public static function getInstance() |
|
| 28 | 28 | { |
| 29 | - if ( self::$instance === null ) |
|
| 29 | + if (self::$instance === null) |
|
| 30 | 30 | { |
| 31 | 31 | self::$instance = new self(); |
| 32 | 32 | } |
@@ -34,20 +34,20 @@ discard block |
||
| 34 | 34 | return self::$instance; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - private function scanDir ( $directory ) |
|
| 37 | + private function scanDir($directory) |
|
| 38 | 38 | { |
| 39 | - if(!is_dir($directory)){ |
|
| 39 | + if ( ! is_dir($directory)) { |
|
| 40 | 40 | return array(); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - $diretories = preg_grep ( '*\.ph*' , scandir ( $directory ) ); |
|
| 44 | - if(!$diretories){ |
|
| 43 | + $diretories = preg_grep('*\.ph*', scandir($directory)); |
|
| 44 | + if ( ! $diretories) { |
|
| 45 | 45 | return array(); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - return array_diff ( $diretories, array ( |
|
| 49 | - '..' , '.' |
|
| 50 | - ) ); |
|
| 48 | + return array_diff($diretories, array( |
|
| 49 | + '..', '.' |
|
| 50 | + )); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -57,14 +57,14 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @return array |
| 59 | 59 | */ |
| 60 | - private function diffFiles ( $path , $driver , $schema = 0 ) |
|
| 60 | + private function diffFiles($path, $driver, $schema = 0) |
|
| 61 | 61 | { |
| 62 | - $tables = $driver->getTables ( $schema ); |
|
| 63 | - if(!$tables instanceof DbTables){ |
|
| 62 | + $tables = $driver->getTables($schema); |
|
| 63 | + if ( ! $tables instanceof DbTables) { |
|
| 64 | 64 | return array(); |
| 65 | 65 | } |
| 66 | 66 | $tablesName = $tables->toArrayFileName(); |
| 67 | - return array_diff ( $this->scanDir ( $path ) , $tablesName ); |
|
| 67 | + return array_diff($this->scanDir($path), $tablesName); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -74,14 +74,14 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @return int |
| 76 | 76 | */ |
| 77 | - public function run ( $path , $driver , $schema = 0 ) |
|
| 77 | + public function run($path, $driver, $schema = 0) |
|
| 78 | 78 | { |
| 79 | 79 | $count = 0; |
| 80 | - foreach ( $this->diffFiles ( $path , $driver , $schema ) as $fileDel ) |
|
| 80 | + foreach ($this->diffFiles($path, $driver, $schema) as $fileDel) |
|
| 81 | 81 | { |
| 82 | - if ( unlink ( $path . DIRECTORY_SEPARATOR . $fileDel ) ) |
|
| 82 | + if (unlink($path . DIRECTORY_SEPARATOR . $fileDel)) |
|
| 83 | 83 | { |
| 84 | - ++ $count; |
|
| 84 | + ++$count; |
|
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | /** |
| 94 | 94 | * @return int |
| 95 | 95 | */ |
| 96 | - public function getNumFilesDeleted () |
|
| 96 | + public function getNumFilesDeleted() |
|
| 97 | 97 | { |
| 98 | 98 | return $this->countFileDeleted; |
| 99 | 99 | } |
@@ -10,13 +10,13 @@ discard block |
||
| 10 | 10 | * |
| 11 | 11 | * @param $dir |
| 12 | 12 | */ |
| 13 | - public static function makeDir ( $dir ) |
|
| 13 | + public static function makeDir($dir) |
|
| 14 | 14 | { |
| 15 | - if ( !is_dir ( $dir ) ) |
|
| 15 | + if ( ! is_dir($dir)) |
|
| 16 | 16 | { |
| 17 | - if ( !@mkdir ( $dir, 0755, true ) ) |
|
| 17 | + if ( ! @mkdir($dir, 0755, true)) |
|
| 18 | 18 | { |
| 19 | - die( "\033[0;31mError: could not create directory $dir\033[0m\n" ); |
|
| 19 | + die("\033[0;31mError: could not create directory $dir\033[0m\n"); |
|
| 20 | 20 | } |
| 21 | 21 | } |
| 22 | 22 | } |
@@ -28,16 +28,16 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @return boolean |
| 30 | 30 | */ |
| 31 | - public static function makeSourcer ( $nameFile, $tplContent, $overwrite = false ) |
|
| 31 | + public static function makeSourcer($nameFile, $tplContent, $overwrite = false) |
|
| 32 | 32 | { |
| 33 | - if ( !$overwrite && is_file ( $nameFile ) ) |
|
| 33 | + if ( ! $overwrite && is_file($nameFile)) |
|
| 34 | 34 | { |
| 35 | 35 | return false; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - if ( !file_put_contents ( $nameFile, $tplContent ) ) |
|
| 38 | + if ( ! file_put_contents($nameFile, $tplContent)) |
|
| 39 | 39 | { |
| 40 | - die( "\033[0;31mError: could not write model file $nameFile.\033[0m\n" ); |
|
| 40 | + die("\033[0;31mError: could not write model file $nameFile.\033[0m\n"); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | return true; |
@@ -48,24 +48,24 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @return string |
| 50 | 50 | */ |
| 51 | - public static function getClassName ( $str ) |
|
| 51 | + public static function getClassName($str) |
|
| 52 | 52 | { |
| 53 | 53 | $temp = ''; |
| 54 | - foreach ( explode ( self::SEPARETOR, $str ) as $part ) |
|
| 54 | + foreach (explode(self::SEPARETOR, $str) as $part) |
|
| 55 | 55 | { |
| 56 | - $temp .= ucfirst ( $part ); |
|
| 56 | + $temp .= ucfirst($part); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | return $temp; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - protected function getParsedTplContents ( $filePath, $vars = array () ) |
|
| 62 | + protected function getParsedTplContents($filePath, $vars = array()) |
|
| 63 | 63 | { |
| 64 | - extract ( $vars ); |
|
| 65 | - ob_start (); |
|
| 64 | + extract($vars); |
|
| 65 | + ob_start(); |
|
| 66 | 66 | require $filePath; |
| 67 | - $data = ob_get_contents (); |
|
| 68 | - ob_end_clean (); |
|
| 67 | + $data = ob_get_contents(); |
|
| 68 | + ob_end_clean(); |
|
| 69 | 69 | |
| 70 | 70 | return $data; |
| 71 | 71 | } |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | foreach ( $this->objDbTables as $objDbTable ) |
| 56 | 56 | { |
| 57 | 57 | $this->toArrayFileName[] = AbstractMaker::getClassName ( $objDbTable->getName () ) |
| 58 | - . '.php'; |
|
| 58 | + . '.php'; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | return $this->toArrayFileName; |
@@ -5,56 +5,56 @@ discard block |
||
| 5 | 5 | use Classes\Db\DbTable; |
| 6 | 6 | use Classes\Maker\AbstractMaker; |
| 7 | 7 | |
| 8 | -class DbTables implements \ArrayAccess , \SeekableIterator , \Countable |
|
| 8 | +class DbTables implements \ArrayAccess, \SeekableIterator, \Countable |
|
| 9 | 9 | { |
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * @type DbTable[] |
| 13 | 13 | */ |
| 14 | - private $objDbTables = array (); |
|
| 14 | + private $objDbTables = array(); |
|
| 15 | 15 | |
| 16 | 16 | private $position = 0; |
| 17 | 17 | |
| 18 | - public function offsetExists ( $offset ) |
|
| 18 | + public function offsetExists($offset) |
|
| 19 | 19 | { |
| 20 | - return isset( $this->objDbTables[ trim ( $offset ) ] ); |
|
| 20 | + return isset($this->objDbTables[trim($offset)]); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public function offsetGet ( $offset ) |
|
| 23 | + public function offsetGet($offset) |
|
| 24 | 24 | { |
| 25 | - return $this->objDbTables[ trim ( $offset ) ]; |
|
| 25 | + return $this->objDbTables[trim($offset)]; |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - public function offsetSet ( $offset , $value ) |
|
| 28 | + public function offsetSet($offset, $value) |
|
| 29 | 29 | { |
| 30 | - return $this->objDbTables[ trim ( $offset ) ] = $value; |
|
| 30 | + return $this->objDbTables[trim($offset)] = $value; |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function offsetUnset ( $offset ) |
|
| 33 | + public function offsetUnset($offset) |
|
| 34 | 34 | { |
| 35 | - unset( $this->objDbTables[ trim ( $offset ) ] ); |
|
| 35 | + unset($this->objDbTables[trim($offset)]); |
|
| 36 | 36 | |
| 37 | 37 | return $this; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - public function count () |
|
| 40 | + public function count() |
|
| 41 | 41 | { |
| 42 | - return count ( $this->objDbTables ); |
|
| 42 | + return count($this->objDbTables); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | 46 | * convert array |
| 47 | 47 | */ |
| 48 | - public function toArrayFileName () |
|
| 48 | + public function toArrayFileName() |
|
| 49 | 49 | { |
| 50 | - if ( ! empty( $this->toArrayFileName ) ) |
|
| 50 | + if ( ! empty($this->toArrayFileName)) |
|
| 51 | 51 | { |
| 52 | 52 | return $this->toArrayFileName; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - foreach ( $this->objDbTables as $objDbTable ) |
|
| 55 | + foreach ($this->objDbTables as $objDbTable) |
|
| 56 | 56 | { |
| 57 | - $this->toArrayFileName[] = AbstractMaker::getClassName ( $objDbTable->getName () ) |
|
| 57 | + $this->toArrayFileName[] = AbstractMaker::getClassName($objDbTable->getName()) |
|
| 58 | 58 | . '.php'; |
| 59 | 59 | } |
| 60 | 60 | |
@@ -63,12 +63,12 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | /* Method required for SeekableIterator interface */ |
| 65 | 65 | |
| 66 | - public function seek ( $position ) |
|
| 66 | + public function seek($position) |
|
| 67 | 67 | { |
| 68 | - $current = array_keys ( $this->objDbTables ); |
|
| 69 | - if ( ! isset( $this->objDbTables[ $current[ $position ] ] ) ) |
|
| 68 | + $current = array_keys($this->objDbTables); |
|
| 69 | + if ( ! isset($this->objDbTables[$current[$position]])) |
|
| 70 | 70 | { |
| 71 | - throw new OutOfBoundsException( "invalid seek position ($position)" ); |
|
| 71 | + throw new OutOfBoundsException("invalid seek position ($position)"); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | $this->position = $position; |
@@ -76,34 +76,34 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | /* Methods required for Iterator interface */ |
| 78 | 78 | |
| 79 | - public function rewind () |
|
| 79 | + public function rewind() |
|
| 80 | 80 | { |
| 81 | 81 | $this->position = 0; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - public function current () |
|
| 84 | + public function current() |
|
| 85 | 85 | { |
| 86 | - $current = array_keys ( $this->objDbTables ); |
|
| 86 | + $current = array_keys($this->objDbTables); |
|
| 87 | 87 | |
| 88 | - return $this->objDbTables[ $current[ $this->position ] ]; |
|
| 88 | + return $this->objDbTables[$current[$this->position]]; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - public function key () |
|
| 91 | + public function key() |
|
| 92 | 92 | { |
| 93 | - $current = array_keys ( $this->objDbTables ); |
|
| 93 | + $current = array_keys($this->objDbTables); |
|
| 94 | 94 | |
| 95 | - return $current[ $this->position ]; |
|
| 95 | + return $current[$this->position]; |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - public function next () |
|
| 98 | + public function next() |
|
| 99 | 99 | { |
| 100 | - ++ $this->position; |
|
| 100 | + ++$this->position; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - public function valid () |
|
| 103 | + public function valid() |
|
| 104 | 104 | { |
| 105 | - $current = array_keys ( $this->objDbTables ); |
|
| 105 | + $current = array_keys($this->objDbTables); |
|
| 106 | 106 | |
| 107 | - return isset( $current[ $this->position ] ); |
|
| 107 | + return isset($current[$this->position]); |
|
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | \ No newline at end of file |