@@ -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 | */ |
@@ -136,8 +136,7 @@ discard block |
||
136 | 136 | unset( $arrUrl ); |
137 | 137 | } |
138 | 138 | |
139 | - } |
|
140 | - else { |
|
139 | + } else { |
|
141 | 140 | $url = array ( |
142 | 141 | $this->baseLocation, |
143 | 142 | $driverBase, |
@@ -213,8 +212,7 @@ discard block |
||
213 | 212 | ); |
214 | 213 | if ( self::makeSourcer ( $file, $tpl, $objMakeFile->isOverwrite () ) ) { |
215 | 214 | ++$numFilesCreated; |
216 | - } |
|
217 | - else { |
|
215 | + } else { |
|
218 | 216 | ++$numFilesIgnored; |
219 | 217 | } |
220 | 218 |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | { |
95 | 95 | foreach ( $arrFoldersName as $index => $folderName ) { |
96 | 96 | $arrFoldersName[ $index ] = $this->getConfig () |
97 | - ->replaceReservedWord ( $folderName ); |
|
97 | + ->replaceReservedWord ( $folderName ); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | return implode ( DIRECTORY_SEPARATOR, array_filter ( $arrFoldersName ) ); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $folderName, |
148 | 148 | $this->getClassName ( |
149 | 149 | $this->getConfig () |
150 | - ->getDatabase () |
|
150 | + ->getDatabase () |
|
151 | 151 | ) |
152 | 152 | ); |
153 | 153 | $this->location = array ( $this->filterLocation ( $url ) ); |
@@ -183,9 +183,9 @@ discard block |
||
183 | 183 | if ( $objFilesFixeds->hasData() ) |
184 | 184 | { |
185 | 185 | $file = $this->baseLocation |
186 | - . DIRECTORY_SEPARATOR |
|
187 | - . $objFilesFixeds->getFileName() |
|
188 | - . '.php'; |
|
186 | + . DIRECTORY_SEPARATOR |
|
187 | + . $objFilesFixeds->getFileName() |
|
188 | + . '.php'; |
|
189 | 189 | |
190 | 190 | $tpl = $this->getParsedTplContents ( $objFilesFixeds->getTpl() ); |
191 | 191 | self::makeSourcer ( $file , $tpl , true ); |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @return String |
320 | 320 | */ |
321 | 321 | protected function getParsedTplContents ( $tplFile, $vars = array (), \Classes\Db\DbTable $objTables = null, |
322 | - $objMakeFile = null ) |
|
322 | + $objMakeFile = null ) |
|
323 | 323 | { |
324 | 324 | |
325 | 325 | $arrUrl = array ( |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | /** |
22 | 22 | * @type string[] |
23 | 23 | */ |
24 | - public $location = array (); |
|
24 | + public $location = array(); |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * caminho de pastas Base |
@@ -45,42 +45,42 @@ discard block |
||
45 | 45 | |
46 | 46 | private $msgReservedWord = "\033[0mPlease enter the value for reserved word \033[0;31m'%index%' \033[1;33m[%config%]:\033[0m "; |
47 | 47 | |
48 | - public function __construct ( Config $config ) |
|
48 | + public function __construct(Config $config) |
|
49 | 49 | { |
50 | - $this->config = $config->getAdapterConfig (); |
|
51 | - $this->parseReservedWord ( $this->getConfig () ); |
|
52 | - $this->driver = $config->getAdapterDriver ( $this->getConfig () ); |
|
53 | - $this->parseLocation ( $config->_basePath ); |
|
50 | + $this->config = $config->getAdapterConfig(); |
|
51 | + $this->parseReservedWord($this->getConfig()); |
|
52 | + $this->driver = $config->getAdapterDriver($this->getConfig()); |
|
53 | + $this->parseLocation($config->_basePath); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
57 | 57 | * @param AdapterConfig\AbstractAdapter $config |
58 | 58 | */ |
59 | - public function parseReservedWord ( AdapterConfig\AbstractAdapter $config ) |
|
59 | + public function parseReservedWord(AdapterConfig\AbstractAdapter $config) |
|
60 | 60 | { |
61 | 61 | $palavrasReservadas = $config->reservedWord; |
62 | - if ( !$palavrasReservadas ) { |
|
62 | + if ( ! $palavrasReservadas) { |
|
63 | 63 | return; |
64 | 64 | } |
65 | 65 | |
66 | - $schema = $config->getSchemas (); |
|
67 | - $db = $config->getDatabase (); |
|
68 | - $hasSchema = array_intersect ( $schema, array_flip ( $palavrasReservadas ) ); |
|
69 | - $hasDatabase = in_array ( $db, $palavrasReservadas ); |
|
70 | - if ( !( $hasSchema or $hasDatabase ) ) { |
|
66 | + $schema = $config->getSchemas(); |
|
67 | + $db = $config->getDatabase(); |
|
68 | + $hasSchema = array_intersect($schema, array_flip($palavrasReservadas)); |
|
69 | + $hasDatabase = in_array($db, $palavrasReservadas); |
|
70 | + if ( ! ($hasSchema or $hasDatabase)) { |
|
71 | 71 | return; |
72 | 72 | } |
73 | 73 | |
74 | 74 | echo "- database has reserved words\n"; |
75 | - foreach ( $palavrasReservadas as $index => $config ) { |
|
76 | - $attribs = array ( |
|
75 | + foreach ($palavrasReservadas as $index => $config) { |
|
76 | + $attribs = array( |
|
77 | 77 | "%index%" => $index, |
78 | 78 | "%config%" => $config |
79 | 79 | ); |
80 | - echo strtr ( $this->msgReservedWord, $attribs ); |
|
81 | - $line = trim ( fgets ( STDIN ) ); |
|
82 | - if ( !empty( $line ) ) { |
|
83 | - $this->getConfig ()->reservedWord[ $index ] = $line; |
|
80 | + echo strtr($this->msgReservedWord, $attribs); |
|
81 | + $line = trim(fgets(STDIN)); |
|
82 | + if ( ! empty($line)) { |
|
83 | + $this->getConfig()->reservedWord[$index] = $line; |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | } |
@@ -90,193 +90,193 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return string |
92 | 92 | */ |
93 | - private function filterLocation ( $arrFoldersName ) |
|
93 | + private function filterLocation($arrFoldersName) |
|
94 | 94 | { |
95 | - foreach ( $arrFoldersName as $index => $folderName ) { |
|
96 | - $arrFoldersName[ $index ] = $this->getConfig () |
|
97 | - ->replaceReservedWord ( $folderName ); |
|
95 | + foreach ($arrFoldersName as $index => $folderName) { |
|
96 | + $arrFoldersName[$index] = $this->getConfig() |
|
97 | + ->replaceReservedWord($folderName); |
|
98 | 98 | } |
99 | 99 | |
100 | - return implode ( DIRECTORY_SEPARATOR, array_filter ( $arrFoldersName ) ); |
|
100 | + return implode(DIRECTORY_SEPARATOR, array_filter($arrFoldersName)); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
104 | 104 | * Analisa os caminhos das pastas base |
105 | 105 | */ |
106 | - public function parseLocation ( $basePath ) |
|
106 | + public function parseLocation($basePath) |
|
107 | 107 | { |
108 | 108 | |
109 | - $arrBase = array ( |
|
109 | + $arrBase = array( |
|
110 | 110 | $basePath, |
111 | 111 | $this->config->path |
112 | 112 | ); |
113 | 113 | |
114 | - $this->baseLocation = $this->filterLocation ( $arrBase ); |
|
114 | + $this->baseLocation = $this->filterLocation($arrBase); |
|
115 | 115 | |
116 | 116 | # pasta com nome do driver do banco |
117 | 117 | $driverBase = ''; |
118 | - if ( (bool) @$this->config->{"folder-database"} ) { |
|
119 | - $classDriver = explode ( '\\', get_class ( $this->driver ) ); |
|
120 | - $driverBase = end ( $classDriver ); |
|
118 | + if ((bool) @$this->config->{"folder-database"} ) { |
|
119 | + $classDriver = explode('\\', get_class($this->driver)); |
|
120 | + $driverBase = end($classDriver); |
|
121 | 121 | } |
122 | 122 | $folderName = ''; |
123 | - if ( (bool) @$this->config->{"folder-name"} ) { |
|
124 | - $folderName = $this->getClassName ( trim ( $this->config->{"folder-name"} ) ); |
|
123 | + if ((bool) @$this->config->{"folder-name"} ) { |
|
124 | + $folderName = $this->getClassName(trim($this->config->{"folder-name"} )); |
|
125 | 125 | } |
126 | 126 | |
127 | - if ( $this->config->hasSchemas () ) { |
|
127 | + if ($this->config->hasSchemas()) { |
|
128 | 128 | |
129 | - $schemas = $this->config->getSchemas (); |
|
130 | - foreach ( $schemas as $schema ) { |
|
131 | - $arrUrl = array ( |
|
129 | + $schemas = $this->config->getSchemas(); |
|
130 | + foreach ($schemas as $schema) { |
|
131 | + $arrUrl = array( |
|
132 | 132 | $this->baseLocation, |
133 | 133 | $driverBase, |
134 | 134 | $folderName, |
135 | - $this->getClassName ( $schema ) |
|
135 | + $this->getClassName($schema) |
|
136 | 136 | ); |
137 | 137 | |
138 | - $this->location[ $schema ] = $this->filterLocation ( $arrUrl ); |
|
139 | - unset( $arrUrl ); |
|
138 | + $this->location[$schema] = $this->filterLocation($arrUrl); |
|
139 | + unset($arrUrl); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | } |
143 | 143 | else { |
144 | - $url = array ( |
|
144 | + $url = array( |
|
145 | 145 | $this->baseLocation, |
146 | 146 | $driverBase, |
147 | 147 | $folderName, |
148 | - $this->getClassName ( |
|
149 | - $this->getConfig () |
|
150 | - ->getDatabase () |
|
148 | + $this->getClassName( |
|
149 | + $this->getConfig() |
|
150 | + ->getDatabase() |
|
151 | 151 | ) |
152 | 152 | ); |
153 | - $this->location = array ( $this->filterLocation ( $url ) ); |
|
154 | - unset( $url ); |
|
153 | + $this->location = array($this->filterLocation($url)); |
|
154 | + unset($url); |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
159 | 159 | * @return AdapterConfig\AbstractAdapter |
160 | 160 | */ |
161 | - public function getConfig () |
|
161 | + public function getConfig() |
|
162 | 162 | { |
163 | 163 | return $this->config; |
164 | 164 | } |
165 | 165 | |
166 | 166 | /* Get current time */ |
167 | - public function startTime () |
|
167 | + public function startTime() |
|
168 | 168 | { |
169 | 169 | echo "\033[1;32mStarting..\033[0m\n"; |
170 | - $this->startTime = microtime ( true ); |
|
170 | + $this->startTime = microtime(true); |
|
171 | 171 | } |
172 | 172 | |
173 | - private function getRunTime () |
|
173 | + private function getRunTime() |
|
174 | 174 | { |
175 | - return round ( ( microtime ( true ) - $this->startTime ), 3 ); |
|
175 | + return round((microtime(true) - $this->startTime), 3); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
179 | 179 | * @param $objMakeFile |
180 | 180 | */ |
181 | - private function generateFilesFixed ( FilesFixeds $objFilesFixeds ) |
|
181 | + private function generateFilesFixed(FilesFixeds $objFilesFixeds) |
|
182 | 182 | { |
183 | - if ( $objFilesFixeds->hasData() ) |
|
183 | + if ($objFilesFixeds->hasData()) |
|
184 | 184 | { |
185 | 185 | $file = $this->baseLocation |
186 | 186 | . DIRECTORY_SEPARATOR |
187 | 187 | . $objFilesFixeds->getFileName() |
188 | 188 | . '.php'; |
189 | 189 | |
190 | - $tpl = $this->getParsedTplContents ( $objFilesFixeds->getTpl() ); |
|
191 | - self::makeSourcer ( $file , $tpl , true ); |
|
190 | + $tpl = $this->getParsedTplContents($objFilesFixeds->getTpl()); |
|
191 | + self::makeSourcer($file, $tpl, true); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
196 | 196 | * Executa o Make, criando arquivos e Diretorios |
197 | 197 | */ |
198 | - public function run () |
|
198 | + public function run() |
|
199 | 199 | { |
200 | 200 | $cur = 0; |
201 | 201 | $numFilesCreated = 0; |
202 | 202 | $numFilesIgnored = 0; |
203 | 203 | |
204 | - $this->startTime (); |
|
204 | + $this->startTime(); |
|
205 | 205 | $this->waitOfDatabase($cur); |
206 | 206 | |
207 | - $this->max = $this->driver->getTotalTables () * $this->countDiretory (); |
|
207 | + $this->max = $this->driver->getTotalTables() * $this->countDiretory(); |
|
208 | 208 | |
209 | - foreach ( $this->location as $schema => $location ) { |
|
210 | - foreach ( $this->factoryMakerFile () as $objMakeFile ) { |
|
211 | - $path = $location . DIRECTORY_SEPARATOR . $objMakeFile->getPastName (); |
|
212 | - if($this->config->isCleanTrash()){ |
|
213 | - CleanTrash::getInstance ()->run ( $path , $this->driver, $schema ); |
|
209 | + foreach ($this->location as $schema => $location) { |
|
210 | + foreach ($this->factoryMakerFile() as $objMakeFile) { |
|
211 | + $path = $location . DIRECTORY_SEPARATOR . $objMakeFile->getPastName(); |
|
212 | + if ($this->config->isCleanTrash()) { |
|
213 | + CleanTrash::getInstance()->run($path, $this->driver, $schema); |
|
214 | 214 | } |
215 | - self::makeDir ( $path ); |
|
215 | + self::makeDir($path); |
|
216 | 216 | |
217 | 217 | #Cria as Classes de Exceção e Abstratas |
218 | - foreach ( $objMakeFile->getListFilesFixed () as $nameObject ) |
|
218 | + foreach ($objMakeFile->getListFilesFixed() as $nameObject) |
|
219 | 219 | { |
220 | 220 | $this->generateFilesFixed($objMakeFile->getFilesFixeds($nameObject)); |
221 | 221 | } |
222 | 222 | |
223 | 223 | #Cria as Classes do Banco |
224 | - foreach ( $this->driver->getTables ( $schema ) as $key => $objTables ) { |
|
225 | - $file = $path . DIRECTORY_SEPARATOR . self::getClassName ( $objTables->getName () ) . '.php'; |
|
224 | + foreach ($this->driver->getTables($schema) as $key => $objTables) { |
|
225 | + $file = $path . DIRECTORY_SEPARATOR . self::getClassName($objTables->getName()) . '.php'; |
|
226 | 226 | |
227 | - $tpl = $this->getParsedTplContents ( |
|
228 | - $objMakeFile->getFileTpl (), |
|
229 | - $objMakeFile->parseRelation ( $this, $objTables ), |
|
227 | + $tpl = $this->getParsedTplContents( |
|
228 | + $objMakeFile->getFileTpl(), |
|
229 | + $objMakeFile->parseRelation($this, $objTables), |
|
230 | 230 | $objTables, |
231 | 231 | $objMakeFile |
232 | 232 | |
233 | 233 | ); |
234 | - if ( self::makeSourcer ( $file, $tpl, $objMakeFile->isOverwrite () ) ) { |
|
234 | + if (self::makeSourcer($file, $tpl, $objMakeFile->isOverwrite())) { |
|
235 | 235 | ++$numFilesCreated; |
236 | 236 | } |
237 | 237 | else { |
238 | 238 | ++$numFilesIgnored; |
239 | 239 | } |
240 | 240 | |
241 | - $this->countCreatedFiles ( $cur ); |
|
241 | + $this->countCreatedFiles($cur); |
|
242 | 242 | } |
243 | 243 | } |
244 | 244 | } |
245 | 245 | |
246 | - $this->reportProcess ( $numFilesCreated, $numFilesIgnored ); |
|
246 | + $this->reportProcess($numFilesCreated, $numFilesIgnored); |
|
247 | 247 | echo "\n\033[1;32mSuccessfully process finished!\n\033[0m"; |
248 | 248 | } |
249 | 249 | |
250 | - private function waitOfDatabase ( &$cur ) |
|
250 | + private function waitOfDatabase(&$cur) |
|
251 | 251 | { |
252 | - printf ( "\033[1;33mWait, the database is being analyzed..\033[0m\n" ); |
|
253 | - $this->driver->runDatabase (); |
|
254 | - printf ( "\r Creating: \033[1;32m%6.2f%%\033[0m", $cur ); |
|
252 | + printf("\033[1;33mWait, the database is being analyzed..\033[0m\n"); |
|
253 | + $this->driver->runDatabase(); |
|
254 | + printf("\r Creating: \033[1;32m%6.2f%%\033[0m", $cur); |
|
255 | 255 | } |
256 | 256 | |
257 | - private function countCreatedFiles ( &$cur ) |
|
257 | + private function countCreatedFiles(&$cur) |
|
258 | 258 | { |
259 | 259 | ++$cur; |
260 | - $total = ( $cur / $this->max ) * 100; |
|
261 | - printf ( "\r Creating: \033[1;32m%6.2f%%\033[0m", $total ); |
|
260 | + $total = ($cur / $this->max) * 100; |
|
261 | + printf("\r Creating: \033[1;32m%6.2f%%\033[0m", $total); |
|
262 | 262 | } |
263 | 263 | |
264 | - private function reportProcess ( $numFilesCreated = 0, $numFilesIgnored = 0 ) |
|
264 | + private function reportProcess($numFilesCreated = 0, $numFilesIgnored = 0) |
|
265 | 265 | { |
266 | - if ( $this->config->isStatusEnabled () ) { |
|
267 | - $databases = count ( $this->location ); |
|
268 | - $countDir = $this->countDiretory (); |
|
269 | - $totalTable = $this->driver->getTotalTables (); |
|
266 | + if ($this->config->isStatusEnabled()) { |
|
267 | + $databases = count($this->location); |
|
268 | + $countDir = $this->countDiretory(); |
|
269 | + $totalTable = $this->driver->getTotalTables(); |
|
270 | 270 | $totalFiles = $numFilesIgnored + $numFilesCreated; |
271 | - $totalFilesDeleted = CleanTrash::getInstance ()->getNumFilesDeleted(); |
|
271 | + $totalFilesDeleted = CleanTrash::getInstance()->getNumFilesDeleted(); |
|
272 | 272 | echo "\n------"; |
273 | - printf ( "\n\r-Files generated/updated: \033[1;33m%s\033[0m" , $numFilesCreated ); |
|
274 | - printf ( "\n\r-Files not upgradeable: \033[1;33m%s\033[0m" , $numFilesIgnored ); |
|
275 | - printf ( "\n\r-Files deleted: \033[1;33m%s\033[0m" , $totalFilesDeleted ); |
|
276 | - printf ( "\n\r-Total files analyzed: \033[1;33m%s of %s\033[0m" , $totalFiles , $this->max ); |
|
277 | - printf ( "\n\r-Diretories: \033[1;33m%s\033[0m" , $databases * $countDir ); |
|
278 | - printf ( "\n\r-Scanned tables: \033[1;33m%s\033[0m" , $totalTable ); |
|
279 | - printf ( "\n\r-Execution time: \033[1;33m%ssec\033[0m" , $this->getRunTime () ); |
|
273 | + printf("\n\r-Files generated/updated: \033[1;33m%s\033[0m", $numFilesCreated); |
|
274 | + printf("\n\r-Files not upgradeable: \033[1;33m%s\033[0m", $numFilesIgnored); |
|
275 | + printf("\n\r-Files deleted: \033[1;33m%s\033[0m", $totalFilesDeleted); |
|
276 | + printf("\n\r-Total files analyzed: \033[1;33m%s of %s\033[0m", $totalFiles, $this->max); |
|
277 | + printf("\n\r-Diretories: \033[1;33m%s\033[0m", $databases * $countDir); |
|
278 | + printf("\n\r-Scanned tables: \033[1;33m%s\033[0m", $totalTable); |
|
279 | + printf("\n\r-Execution time: \033[1;33m%ssec\033[0m", $this->getRunTime()); |
|
280 | 280 | echo "\n------"; |
281 | 281 | } |
282 | 282 | } |
@@ -286,9 +286,9 @@ discard block |
||
286 | 286 | * |
287 | 287 | * @return AbstractAdapter[] |
288 | 288 | */ |
289 | - public function factoryMakerFile () |
|
289 | + public function factoryMakerFile() |
|
290 | 290 | { |
291 | - return $this->config->getMakeFileInstances (); |
|
291 | + return $this->config->getMakeFileInstances(); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | /** |
@@ -296,12 +296,12 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @return int |
298 | 298 | */ |
299 | - public function countDiretory () |
|
299 | + public function countDiretory() |
|
300 | 300 | { |
301 | - if ( null === $this->countDir ) { |
|
301 | + if (null === $this->countDir) { |
|
302 | 302 | $this->countDir = 1; |
303 | - foreach ( $this->factoryMakerFile () as $abstractAdapter ) { |
|
304 | - if ( $abstractAdapter->hasDiretory () ) { |
|
303 | + foreach ($this->factoryMakerFile() as $abstractAdapter) { |
|
304 | + if ($abstractAdapter->hasDiretory()) { |
|
305 | 305 | ++$this->countDir; |
306 | 306 | } |
307 | 307 | } |
@@ -318,24 +318,24 @@ discard block |
||
318 | 318 | * |
319 | 319 | * @return String |
320 | 320 | */ |
321 | - protected function getParsedTplContents ( $tplFile, $vars = array (), \Classes\Db\DbTable $objTables = null, |
|
322 | - $objMakeFile = null ) |
|
321 | + protected function getParsedTplContents($tplFile, $vars = array(), \Classes\Db\DbTable $objTables = null, |
|
322 | + $objMakeFile = null) |
|
323 | 323 | { |
324 | 324 | |
325 | - $arrUrl = array ( |
|
325 | + $arrUrl = array( |
|
326 | 326 | __DIR__, |
327 | 327 | 'templates', |
328 | 328 | $this->config->framework, |
329 | 329 | $tplFile |
330 | 330 | ); |
331 | 331 | |
332 | - $filePath = implode ( DIRECTORY_SEPARATOR, filter_var_array ( $arrUrl ) ); |
|
332 | + $filePath = implode(DIRECTORY_SEPARATOR, filter_var_array($arrUrl)); |
|
333 | 333 | |
334 | - extract ( $vars ); |
|
335 | - ob_start (); |
|
334 | + extract($vars); |
|
335 | + ob_start(); |
|
336 | 336 | require $filePath; |
337 | - $data = ob_get_contents (); |
|
338 | - ob_end_clean (); |
|
337 | + $data = ob_get_contents(); |
|
338 | + ob_end_clean(); |
|
339 | 339 | |
340 | 340 | return $data; |
341 | 341 | } |
@@ -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 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | $configIni = isset( $argv[ 'name-ini' ] ) |
193 | 193 | ? $argv[ 'name-ini' ] |
194 | 194 | : $this->_basePath |
195 | - . $this->configIniDefault; |
|
195 | + . $this->configIniDefault; |
|
196 | 196 | |
197 | 197 | $configTemp = $this->loadIniFile ( realpath ( $configIni ) ); |
198 | 198 | $configCurrent = self::parseConfigEnv ( $configTemp , $argv ); |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | { |
207 | 207 | $frameworks = implode ( "\n\t" , $this->frameworkList ); |
208 | 208 | throw new \Exception( "list of frameworks: \n\t\033[1;33m" . $frameworks |
209 | - . "\n\033[0m" ); |
|
209 | + . "\n\033[0m" ); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | return $argv + array_filter ( $configCurrent ); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * @var array |
54 | 54 | */ |
55 | - private $argv = array (); |
|
55 | + private $argv = array(); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * @var \Classes\AdapterConfig\AbstractAdapter |
@@ -64,46 +64,46 @@ discard block |
||
64 | 64 | */ |
65 | 65 | private $adapterDriver; |
66 | 66 | |
67 | - private $frameworkList = array ( |
|
68 | - 'none' , |
|
69 | - 'zf1' , |
|
67 | + private $frameworkList = array( |
|
68 | + 'none', |
|
69 | + 'zf1', |
|
70 | 70 | 'phalcon' |
71 | 71 | ); |
72 | 72 | |
73 | - private $parameterList = array ( |
|
74 | - 'init' => 'Creates the necessary configuration file to start using the orm-generator.' , |
|
75 | - 'name-ini' => 'reference to another .ini file configuration (relative path).' , |
|
76 | - 'config-env' => 'orm-generator configuration environment.' , |
|
77 | - 'framework' => 'name framework used, which has the contents of the database configurations and framework template.' , |
|
78 | - 'driver' => 'database driver name (Ex.: pgsql).' , |
|
79 | - 'database' => 'database name.' , |
|
80 | - 'schema' => 'database schema name (one or more than one).' , |
|
81 | - 'tables' => 'table name (parameter can be used more then once).' , |
|
82 | - 'clean-trash' => 'delete all files that do not belong to your Database due' , |
|
83 | - 'status' => 'show status of implementation carried out after completing the process.' , |
|
84 | - 'version' => 'shows the version of orm-generator.' , |
|
85 | - 'help' => "help command explaining all the options and manner of use." , |
|
86 | - 'path' => "specify where to create the files (default is current directory)." , |
|
73 | + private $parameterList = array( |
|
74 | + 'init' => 'Creates the necessary configuration file to start using the orm-generator.', |
|
75 | + 'name-ini' => 'reference to another .ini file configuration (relative path).', |
|
76 | + 'config-env' => 'orm-generator configuration environment.', |
|
77 | + 'framework' => 'name framework used, which has the contents of the database configurations and framework template.', |
|
78 | + 'driver' => 'database driver name (Ex.: pgsql).', |
|
79 | + 'database' => 'database name.', |
|
80 | + 'schema' => 'database schema name (one or more than one).', |
|
81 | + 'tables' => 'table name (parameter can be used more then once).', |
|
82 | + 'clean-trash' => 'delete all files that do not belong to your Database due', |
|
83 | + 'status' => 'show status of implementation carried out after completing the process.', |
|
84 | + 'version' => 'shows the version of orm-generator.', |
|
85 | + 'help' => "help command explaining all the options and manner of use.", |
|
86 | + 'path' => "specify where to create the files (default is current directory).", |
|
87 | 87 | ); |
88 | 88 | |
89 | - public function __construct ( $argv , $basePath , $numArgs ) |
|
89 | + public function __construct($argv, $basePath, $numArgs) |
|
90 | 90 | { |
91 | - if ( array_key_exists ( 'help' , $argv ) or ( $numArgs > 1 |
|
92 | - && count ( $argv ) < 1 ) |
|
91 | + if (array_key_exists('help', $argv) or ($numArgs > 1 |
|
92 | + && count($argv) < 1) |
|
93 | 93 | ) |
94 | 94 | { |
95 | - die ( $this->getUsage () ); |
|
95 | + die ($this->getUsage()); |
|
96 | 96 | } |
97 | - if ( array_key_exists ( 'version' , $argv ) ) |
|
97 | + if (array_key_exists('version', $argv)) |
|
98 | 98 | { |
99 | - die ( $this->getVersion () ); |
|
99 | + die ($this->getVersion()); |
|
100 | 100 | } |
101 | - if ( array_key_exists ( 'status' , $argv ) ) |
|
101 | + if (array_key_exists('status', $argv)) |
|
102 | 102 | { |
103 | - $argv[ 'status' ] = true; |
|
103 | + $argv['status'] = true; |
|
104 | 104 | } |
105 | 105 | |
106 | - $this->argv = $this->parseConfig ( $basePath , $argv ); |
|
106 | + $this->argv = $this->parseConfig($basePath, $argv); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -111,10 +111,10 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @return string |
113 | 113 | */ |
114 | - public function getUsage () |
|
114 | + public function getUsage() |
|
115 | 115 | { |
116 | - $version = $this->getVersion (); |
|
117 | - $list = $this->renderParam (); |
|
116 | + $version = $this->getVersion(); |
|
117 | + $list = $this->renderParam(); |
|
118 | 118 | |
119 | 119 | return <<<EOF |
120 | 120 | parameters: |
@@ -125,12 +125,12 @@ discard block |
||
125 | 125 | EOF; |
126 | 126 | } |
127 | 127 | |
128 | - public function renderParam () |
|
128 | + public function renderParam() |
|
129 | 129 | { |
130 | 130 | $return = ""; |
131 | - foreach ( $this->parameterList as $param => $desc ) |
|
131 | + foreach ($this->parameterList as $param => $desc) |
|
132 | 132 | { |
133 | - if ( strlen ( $param ) < 5 ) |
|
133 | + if (strlen($param) < 5) |
|
134 | 134 | { |
135 | 135 | $return .= "\t--" . $param . "\t\t: " . $desc . "\n"; |
136 | 136 | } else |
@@ -143,12 +143,12 @@ discard block |
||
143 | 143 | return $return; |
144 | 144 | } |
145 | 145 | |
146 | - public function checkHasNewVersion () |
|
146 | + public function checkHasNewVersion() |
|
147 | 147 | { |
148 | - $opts = array ( |
|
149 | - 'http' => array ( |
|
150 | - 'method' => 'GET' , |
|
151 | - 'header' => array ( |
|
148 | + $opts = array( |
|
149 | + 'http' => array( |
|
150 | + 'method' => 'GET', |
|
151 | + 'header' => array( |
|
152 | 152 | 'User-Agent: PHP' |
153 | 153 | ) |
154 | 154 | ) |
@@ -156,22 +156,22 @@ discard block |
||
156 | 156 | |
157 | 157 | try |
158 | 158 | { |
159 | - $context = stream_context_create ( $opts ); |
|
160 | - $tags = json_decode ( file_get_contents ( "https://api.github.com/repos/pedro151/orm-generator/tags" , false , $context ) ); |
|
159 | + $context = stream_context_create($opts); |
|
160 | + $tags = json_decode(file_get_contents("https://api.github.com/repos/pedro151/orm-generator/tags", false, $context)); |
|
161 | 161 | |
162 | - $lastVersion = preg_replace ( "/[^0-9.]/" , "" , $tags[ 0 ]->name ); |
|
163 | - if ( $lastVersion > static::$version ) |
|
162 | + $lastVersion = preg_replace("/[^0-9.]/", "", $tags[0]->name); |
|
163 | + if ($lastVersion > static::$version) |
|
164 | 164 | { |
165 | 165 | return "\033[0;31mThere is a new version $lastVersion available:\033[0m https://github.com/pedro151/orm-generator\n"; |
166 | 166 | } |
167 | - } catch ( \Exception $ex ){ } |
|
167 | + } catch (\Exception $ex) { } |
|
168 | 168 | } |
169 | 169 | |
170 | - public function getVersion () |
|
170 | + public function getVersion() |
|
171 | 171 | { |
172 | 172 | $version = static::$version; |
173 | 173 | |
174 | - return "ORM Generator By: Pedro Alarcao Version: $version\n".$this->checkHasNewVersion(); |
|
174 | + return "ORM Generator By: Pedro Alarcao Version: $version\n" . $this->checkHasNewVersion(); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -183,31 +183,31 @@ discard block |
||
183 | 183 | * @return array |
184 | 184 | * @throws \Exception |
185 | 185 | */ |
186 | - private function parseConfig ( $basePath , $argv ) |
|
186 | + private function parseConfig($basePath, $argv) |
|
187 | 187 | { |
188 | 188 | $this->_basePath = $basePath; |
189 | 189 | |
190 | - $configIni = isset( $argv[ 'name-ini' ] ) |
|
191 | - ? $argv[ 'name-ini' ] |
|
190 | + $configIni = isset($argv['name-ini']) |
|
191 | + ? $argv['name-ini'] |
|
192 | 192 | : $this->_basePath |
193 | 193 | . $this->configIniDefault; |
194 | 194 | |
195 | - $configTemp = $this->loadIniFile ( realpath ( $configIni ) ); |
|
196 | - $configCurrent = self::parseConfigEnv ( $configTemp , $argv ); |
|
195 | + $configTemp = $this->loadIniFile(realpath($configIni)); |
|
196 | + $configCurrent = self::parseConfigEnv($configTemp, $argv); |
|
197 | 197 | |
198 | - if ( ! isset( $configCurrent[ 'framework' ] ) ) |
|
198 | + if ( ! isset($configCurrent['framework'])) |
|
199 | 199 | { |
200 | - throw new \Exception( "configure which framework you want to use! \n" ); |
|
200 | + throw new \Exception("configure which framework you want to use! \n"); |
|
201 | 201 | } |
202 | 202 | |
203 | - if ( ! in_array ( $configCurrent[ 'framework' ] , $this->frameworkList ) ) |
|
203 | + if ( ! in_array($configCurrent['framework'], $this->frameworkList)) |
|
204 | 204 | { |
205 | - $frameworks = implode ( "\n\t" , $this->frameworkList ); |
|
206 | - throw new \Exception( "list of frameworks: \n\t\033[1;33m" . $frameworks |
|
207 | - . "\n\033[0m" ); |
|
205 | + $frameworks = implode("\n\t", $this->frameworkList); |
|
206 | + throw new \Exception("list of frameworks: \n\t\033[1;33m" . $frameworks |
|
207 | + . "\n\033[0m"); |
|
208 | 208 | } |
209 | 209 | |
210 | - return $argv + array_filter ( $configCurrent ); |
|
210 | + return $argv + array_filter($configCurrent); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -217,24 +217,24 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @return string |
219 | 219 | */ |
220 | - private static function parseConfigEnv ( $configTemp , $argv ) |
|
220 | + private static function parseConfigEnv($configTemp, $argv) |
|
221 | 221 | { |
222 | - $thisSection = isset( $configTemp[ key ( $configTemp ) ][ 'config-env' ] ) |
|
223 | - ? $configTemp[ key ( |
|
222 | + $thisSection = isset($configTemp[key($configTemp)]['config-env']) |
|
223 | + ? $configTemp[key( |
|
224 | 224 | $configTemp |
225 | - ) ][ 'config-env' ] : null; |
|
225 | + )]['config-env'] : null; |
|
226 | 226 | |
227 | - $thisSection = isset( $argv[ 'config-env' ] ) ? $argv[ 'config-env' ] |
|
227 | + $thisSection = isset($argv['config-env']) ? $argv['config-env'] |
|
228 | 228 | : $thisSection; |
229 | 229 | |
230 | - if ( isset( $configTemp[ $thisSection ][ 'extends' ] ) ) |
|
230 | + if (isset($configTemp[$thisSection]['extends'])) |
|
231 | 231 | { |
232 | 232 | #faz marge da config principal com a config extendida |
233 | - return $configTemp[ $thisSection ] |
|
234 | - + $configTemp[ $configTemp[ $thisSection ][ 'extends' ] ]; |
|
233 | + return $configTemp[$thisSection] |
|
234 | + + $configTemp[$configTemp[$thisSection]['extends']]; |
|
235 | 235 | } |
236 | 236 | |
237 | - return $configTemp[ key ( $configTemp ) ]; |
|
237 | + return $configTemp[key($configTemp)]; |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -248,32 +248,32 @@ discard block |
||
248 | 248 | * @throws \Exception |
249 | 249 | * @return array |
250 | 250 | */ |
251 | - protected function loadIniFile ( $filename ) |
|
251 | + protected function loadIniFile($filename) |
|
252 | 252 | { |
253 | - if ( ! is_file ( $filename ) ) |
|
253 | + if ( ! is_file($filename)) |
|
254 | 254 | { |
255 | - throw new \Exception( "\033[0;31mError: configuration file does not exist! \033[0m\n" ); |
|
255 | + throw new \Exception("\033[0;31mError: configuration file does not exist! \033[0m\n"); |
|
256 | 256 | } |
257 | 257 | |
258 | - $loaded = parse_ini_file ( $filename , true ); |
|
259 | - $iniArray = array (); |
|
260 | - foreach ( $loaded as $key => $data ) |
|
258 | + $loaded = parse_ini_file($filename, true); |
|
259 | + $iniArray = array(); |
|
260 | + foreach ($loaded as $key => $data) |
|
261 | 261 | { |
262 | - $pieces = explode ( $this->sectionSeparator , $key ); |
|
263 | - $thisSection = trim ( $pieces[ 0 ] ); |
|
264 | - switch ( count ( $pieces ) ) |
|
262 | + $pieces = explode($this->sectionSeparator, $key); |
|
263 | + $thisSection = trim($pieces[0]); |
|
264 | + switch (count($pieces)) |
|
265 | 265 | { |
266 | 266 | case 1: |
267 | - $iniArray[ $thisSection ] = $data; |
|
267 | + $iniArray[$thisSection] = $data; |
|
268 | 268 | break; |
269 | 269 | |
270 | 270 | case 2: |
271 | - $extendedSection = trim ( $pieces[ 1 ] ); |
|
272 | - $iniArray[ $thisSection ] = array_merge ( array ( 'extends' => $extendedSection ) , $data ); |
|
271 | + $extendedSection = trim($pieces[1]); |
|
272 | + $iniArray[$thisSection] = array_merge(array('extends' => $extendedSection), $data); |
|
273 | 273 | break; |
274 | 274 | |
275 | 275 | default: |
276 | - throw new \Exception( "Section '$thisSection' may not extend multiple sections in $filename" ); |
|
276 | + throw new \Exception("Section '$thisSection' may not extend multiple sections in $filename"); |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | |
@@ -286,16 +286,16 @@ discard block |
||
286 | 286 | * @return \Classes\AdapterConfig\AbstractAdapter |
287 | 287 | * |
288 | 288 | */ |
289 | - private function factoryConfig () |
|
289 | + private function factoryConfig() |
|
290 | 290 | { |
291 | - switch ( strtolower ( $this->argv[ 'framework' ] ) ) |
|
291 | + switch (strtolower($this->argv['framework'])) |
|
292 | 292 | { |
293 | 293 | case 'zf1': |
294 | - return new ZendFrameworkOne( $this->argv ); |
|
294 | + return new ZendFrameworkOne($this->argv); |
|
295 | 295 | case 'phalcon': |
296 | - return new Phalcon( $this->argv ); |
|
296 | + return new Phalcon($this->argv); |
|
297 | 297 | default: |
298 | - return new None( $this->argv ); |
|
298 | + return new None($this->argv); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | } |
@@ -307,33 +307,33 @@ discard block |
||
307 | 307 | * |
308 | 308 | * @return AdaptersDriver\AbsractAdapter |
309 | 309 | */ |
310 | - private function factoryDriver ( AdapterConfig\AbstractAdapter $config ) |
|
310 | + private function factoryDriver(AdapterConfig\AbstractAdapter $config) |
|
311 | 311 | { |
312 | - switch ( $this->argv[ 'driver' ] ) |
|
312 | + switch ($this->argv['driver']) |
|
313 | 313 | { |
314 | 314 | case 'pgsql': |
315 | 315 | case 'pdo_pgsql': |
316 | - return new Pgsql( $config ); |
|
316 | + return new Pgsql($config); |
|
317 | 317 | case 'mysql': |
318 | 318 | case 'pdo_mysql': |
319 | - return new Mysql( $config ); |
|
319 | + return new Mysql($config); |
|
320 | 320 | case 'mssql': |
321 | - return new Mssql( $config ); |
|
321 | + return new Mssql($config); |
|
322 | 322 | case 'dblib': |
323 | - return new Dblib( $config ); |
|
323 | + return new Dblib($config); |
|
324 | 324 | case 'sqlsrv': |
325 | - return new Sqlsrv( $config ); |
|
325 | + return new Sqlsrv($config); |
|
326 | 326 | } |
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
330 | 330 | * @return AdapterConfig\AbstractAdapter |
331 | 331 | */ |
332 | - public function getAdapterConfig () |
|
332 | + public function getAdapterConfig() |
|
333 | 333 | { |
334 | - if ( ! $this->adapterConfig instanceof AbstractAdapter ) |
|
334 | + if ( ! $this->adapterConfig instanceof AbstractAdapter) |
|
335 | 335 | { |
336 | - $this->adapterConfig = $this->factoryConfig (); |
|
336 | + $this->adapterConfig = $this->factoryConfig(); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | return $this->adapterConfig; |
@@ -342,11 +342,11 @@ discard block |
||
342 | 342 | /** |
343 | 343 | * @return AdaptersDriver\AbsractAdapter |
344 | 344 | */ |
345 | - public function getAdapterDriver ( AdapterConfig\AbstractAdapter $config ) |
|
345 | + public function getAdapterDriver(AdapterConfig\AbstractAdapter $config) |
|
346 | 346 | { |
347 | - if ( ! $this->adapterDriver ) |
|
347 | + if ( ! $this->adapterDriver) |
|
348 | 348 | { |
349 | - $this->adapterDriver = $this->factoryDriver ( $config ); |
|
349 | + $this->adapterDriver = $this->factoryDriver($config); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | return $this->adapterDriver; |