@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @author Pedro Alarcao <[email protected]> |
24 | 24 | */ |
25 | - final private function __construct () |
|
25 | + final private function __construct() |
|
26 | 26 | { |
27 | 27 | } |
28 | 28 | |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @return \Classes\Db\Column |
33 | 33 | */ |
34 | - public static function getInstance () |
|
34 | + public static function getInstance() |
|
35 | 35 | { |
36 | 36 | return new Column(); |
37 | 37 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | /** |
90 | 90 | * @return string |
91 | 91 | */ |
92 | - public function getName () |
|
92 | + public function getName() |
|
93 | 93 | { |
94 | 94 | return $this->name; |
95 | 95 | } |
@@ -99,13 +99,13 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @param $array |
101 | 101 | */ |
102 | - public function populate ( $array ) |
|
102 | + public function populate($array) |
|
103 | 103 | { |
104 | - $this->name = $array[ 'name' ]; |
|
105 | - $this->type = $array[ 'type' ]; |
|
106 | - $this->nullable = $array[ 'nullable' ]; |
|
107 | - $this->max_length = $array[ 'max_length' ]; |
|
108 | - $this->column_default = $array[ 'column_default' ]; |
|
104 | + $this->name = $array['name']; |
|
105 | + $this->type = $array['type']; |
|
106 | + $this->nullable = $array['nullable']; |
|
107 | + $this->max_length = $array['max_length']; |
|
108 | + $this->column_default = $array['column_default']; |
|
109 | 109 | |
110 | 110 | return $this; |
111 | 111 | } |
@@ -113,54 +113,54 @@ discard block |
||
113 | 113 | /** |
114 | 114 | * @return boolean |
115 | 115 | */ |
116 | - public function isPrimaryKey () |
|
116 | + public function isPrimaryKey() |
|
117 | 117 | { |
118 | - return !empty( $this->primarykey ); |
|
118 | + return ! empty($this->primarykey); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
122 | 122 | * @return boolean |
123 | 123 | */ |
124 | - public function isForeingkey () |
|
124 | + public function isForeingkey() |
|
125 | 125 | { |
126 | - return !empty( $this->refForeingkey ); |
|
126 | + return ! empty($this->refForeingkey); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
130 | 130 | * @return boolean |
131 | 131 | */ |
132 | - public function hasDependence () |
|
132 | + public function hasDependence() |
|
133 | 133 | { |
134 | - return !empty( $this->dependences ); |
|
134 | + return ! empty($this->dependences); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
138 | 138 | * @return boolean |
139 | 139 | */ |
140 | - public function hasColumnDefault () |
|
140 | + public function hasColumnDefault() |
|
141 | 141 | { |
142 | - return !empty( $this->column_default ); |
|
142 | + return ! empty($this->column_default); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
146 | 146 | * @return string |
147 | 147 | */ |
148 | - public function getColumnDefault () |
|
148 | + public function getColumnDefault() |
|
149 | 149 | { |
150 | - return $this->column_default ; |
|
150 | + return $this->column_default; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
154 | 154 | * @return string |
155 | 155 | */ |
156 | - public function getType ( $type = self::TypeDefault ) |
|
156 | + public function getType($type = self::TypeDefault) |
|
157 | 157 | { |
158 | - switch ( $type ) |
|
158 | + switch ($type) |
|
159 | 159 | { |
160 | 160 | case self::TypePHP: |
161 | - return AbstractAdapter::convertTypeToPHP ( $this->type ); |
|
161 | + return AbstractAdapter::convertTypeToPHP($this->type); |
|
162 | 162 | case self::TypeDefault: |
163 | - return AbstractAdapter::convertTypeToDefault ( $this->type ); |
|
163 | + return AbstractAdapter::convertTypeToDefault($this->type); |
|
164 | 164 | case self::TypeNone: |
165 | 165 | return $this->type; |
166 | 166 | } |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return bool |
174 | 174 | */ |
175 | - public function equalType ( $type, $inPHP = true ) |
|
175 | + public function equalType($type, $inPHP = true) |
|
176 | 176 | { |
177 | - return $this->getType ( $inPHP ) === $type; |
|
177 | + return $this->getType($inPHP) === $type; |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
@@ -182,15 +182,15 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @return mixed |
184 | 184 | */ |
185 | - public function getTypeByConfig ( AbstractAdapter $type ) |
|
185 | + public function getTypeByConfig(AbstractAdapter $type) |
|
186 | 186 | { |
187 | - return $type->convertTypeToTypeFramework ( $this->getType ( false ) ); |
|
187 | + return $type->convertTypeToTypeFramework($this->getType(false)); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
191 | 191 | * @return string |
192 | 192 | */ |
193 | - public function getComment () |
|
193 | + public function getComment() |
|
194 | 194 | { |
195 | 195 | return $this->comment; |
196 | 196 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | /** |
199 | 199 | * @param string $comment |
200 | 200 | */ |
201 | - public function setComment ( $comment ) |
|
201 | + public function setComment($comment) |
|
202 | 202 | { |
203 | 203 | $this->comment = $comment; |
204 | 204 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | /** |
209 | 209 | * @param \Classes\Db\Constrant $primarykey |
210 | 210 | */ |
211 | - public function setPrimaryKey ( Constrant $primarykey ) |
|
211 | + public function setPrimaryKey(Constrant $primarykey) |
|
212 | 212 | { |
213 | 213 | $this->primarykey = $primarykey; |
214 | 214 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | /** |
219 | 219 | * @param \Classes\Db\Constrant $dependece |
220 | 220 | */ |
221 | - public function addDependece ( Constrant $dependece ) |
|
221 | + public function addDependece(Constrant $dependece) |
|
222 | 222 | { |
223 | 223 | $this->dependences[] = $dependece; |
224 | 224 | |
@@ -232,11 +232,11 @@ discard block |
||
232 | 232 | * |
233 | 233 | * @return $this |
234 | 234 | */ |
235 | - public function createDependece ( $constraint_name, $table_name, $column_name, $database, $schema = null ) |
|
235 | + public function createDependece($constraint_name, $table_name, $column_name, $database, $schema = null) |
|
236 | 236 | { |
237 | - $objConstrantDependence = Constrant::getInstance () |
|
238 | - ->populate ( |
|
239 | - array ( |
|
237 | + $objConstrantDependence = Constrant::getInstance() |
|
238 | + ->populate( |
|
239 | + array( |
|
240 | 240 | 'constrant' => $constraint_name, |
241 | 241 | 'schema' => $schema, |
242 | 242 | 'table' => $table_name, |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | ) |
246 | 246 | ); |
247 | 247 | |
248 | - $this->addDependece ( $objConstrantDependence ); |
|
248 | + $this->addDependece($objConstrantDependence); |
|
249 | 249 | |
250 | 250 | return $this; |
251 | 251 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | /** |
254 | 254 | * @param \Classes\Db\Constrant $reference |
255 | 255 | */ |
256 | - public function addRefFk ( Constrant $reference ) |
|
256 | + public function addRefFk(Constrant $reference) |
|
257 | 257 | { |
258 | 258 | $this->refForeingkey = $reference; |
259 | 259 | |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @return \Classes\Db\Constrant |
267 | 267 | */ |
268 | - public function getFks () |
|
268 | + public function getFks() |
|
269 | 269 | { |
270 | 270 | return $this->refForeingkey; |
271 | 271 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @return \Classes\Db\Constrant[] |
277 | 277 | */ |
278 | - public function getDependences () |
|
278 | + public function getDependences() |
|
279 | 279 | { |
280 | 280 | return $this->dependences; |
281 | 281 | } |
@@ -283,9 +283,9 @@ discard block |
||
283 | 283 | /** |
284 | 284 | * @return bool |
285 | 285 | */ |
286 | - public function hasDependences () |
|
286 | + public function hasDependences() |
|
287 | 287 | { |
288 | - return (bool) count ( $this->dependences ); |
|
288 | + return (bool) count($this->dependences); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @return \Classes\Db\Constrant[] |
295 | 295 | */ |
296 | - public function getPrimaryKey () |
|
296 | + public function getPrimaryKey() |
|
297 | 297 | { |
298 | 298 | return $this->primarykey; |
299 | 299 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | /** |
302 | 302 | * |
303 | 303 | */ |
304 | - public function getMaxLength () |
|
304 | + public function getMaxLength() |
|
305 | 305 | { |
306 | 306 | return $this->max_length; |
307 | 307 | } |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | /** |
310 | 310 | * @return bool |
311 | 311 | */ |
312 | - public function hasSequence () |
|
312 | + public function hasSequence() |
|
313 | 313 | { |
314 | 314 | return (bool) $this->sequence; |
315 | 315 | } |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | /** |
318 | 318 | * @return string |
319 | 319 | */ |
320 | - public function getSequence () |
|
320 | + public function getSequence() |
|
321 | 321 | { |
322 | 322 | return $this->sequence; |
323 | 323 | } |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | /** |
326 | 326 | * @param string $sequence |
327 | 327 | */ |
328 | - public function setSequence ( $sequence ) |
|
328 | + public function setSequence($sequence) |
|
329 | 329 | { |
330 | 330 | $this->sequence = $sequence; |
331 | 331 | } |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | /** |
334 | 334 | * @return boolean |
335 | 335 | */ |
336 | - public function isNullable () |
|
336 | + public function isNullable() |
|
337 | 337 | { |
338 | 338 | return $this->nullable; |
339 | 339 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | /** |
56 | 56 | * @var array |
57 | 57 | */ |
58 | - private $argv = array (); |
|
58 | + private $argv = array(); |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * @var \Classes\AdapterConfig\AbstractAdapter |
@@ -67,58 +67,58 @@ discard block |
||
67 | 67 | */ |
68 | 68 | private $adapterDriver; |
69 | 69 | |
70 | - private $frameworkList = array ( |
|
71 | - 'none' , |
|
72 | - 'zf1' , |
|
70 | + private $frameworkList = array( |
|
71 | + 'none', |
|
72 | + 'zf1', |
|
73 | 73 | 'phalcon' |
74 | 74 | ); |
75 | 75 | |
76 | - private $parameterList = array ( |
|
77 | - 'init' => 'Creates the necessary configuration file to start using the orm-generator.' , |
|
78 | - 'name-ini' => 'reference to another .ini file configuration (relative path).' , |
|
79 | - 'config-env' => 'orm-generator configuration environment.' , |
|
80 | - 'framework' => 'name framework used, which has the contents of the database configurations and framework template.' , |
|
81 | - 'driver' => 'database driver name (Ex.: pgsql).' , |
|
82 | - 'database' => 'database name.' , |
|
83 | - 'schema' => 'database schema name (one or more than one).' , |
|
84 | - 'tables' => 'table name (parameter can be used more then once).' , |
|
85 | - 'optional-classes' => 'List of optional Predefined classes to be created (Consult in github the list of each framework).' , |
|
86 | - 'clean-trash' => 'delete all files that do not belong to your Database due' , |
|
87 | - 'status' => 'show status of implementation carried out after completing the process.' , |
|
88 | - 'version' => 'shows the version of orm-generator.' , |
|
89 | - 'help' => "help command explaining all the options and manner of use." , |
|
90 | - 'path' => "specify where to create the files (default is current directory)." , |
|
91 | - 'update' => "Upgrade to latest version." , |
|
76 | + private $parameterList = array( |
|
77 | + 'init' => 'Creates the necessary configuration file to start using the orm-generator.', |
|
78 | + 'name-ini' => 'reference to another .ini file configuration (relative path).', |
|
79 | + 'config-env' => 'orm-generator configuration environment.', |
|
80 | + 'framework' => 'name framework used, which has the contents of the database configurations and framework template.', |
|
81 | + 'driver' => 'database driver name (Ex.: pgsql).', |
|
82 | + 'database' => 'database name.', |
|
83 | + 'schema' => 'database schema name (one or more than one).', |
|
84 | + 'tables' => 'table name (parameter can be used more then once).', |
|
85 | + 'optional-classes' => 'List of optional Predefined classes to be created (Consult in github the list of each framework).', |
|
86 | + 'clean-trash' => 'delete all files that do not belong to your Database due', |
|
87 | + 'status' => 'show status of implementation carried out after completing the process.', |
|
88 | + 'version' => 'shows the version of orm-generator.', |
|
89 | + 'help' => "help command explaining all the options and manner of use.", |
|
90 | + 'path' => "specify where to create the files (default is current directory).", |
|
91 | + 'update' => "Upgrade to latest version.", |
|
92 | 92 | 'download' => "download the reported version (ex. --download=1.5.0). " |
93 | 93 | ); |
94 | 94 | |
95 | - public function __construct ( $argv , $basePath , $numArgs ) |
|
95 | + public function __construct($argv, $basePath, $numArgs) |
|
96 | 96 | { |
97 | - if ( array_key_exists ( 'help' , $argv ) or ( $numArgs > 1 |
|
98 | - && count ( $argv ) < 1 ) |
|
97 | + if (array_key_exists('help', $argv) or ($numArgs > 1 |
|
98 | + && count($argv) < 1) |
|
99 | 99 | ) |
100 | 100 | { |
101 | - die ( $this->getUsage () ); |
|
101 | + die ($this->getUsage()); |
|
102 | 102 | } |
103 | - if ( array_key_exists ( 'version' , $argv ) ) |
|
103 | + if (array_key_exists('version', $argv)) |
|
104 | 104 | { |
105 | - die ( $this->getVersion () ); |
|
105 | + die ($this->getVersion()); |
|
106 | 106 | } |
107 | - if ( array_key_exists ( 'status' , $argv ) ) |
|
107 | + if (array_key_exists('status', $argv)) |
|
108 | 108 | { |
109 | - $argv[ 'status' ] = true; |
|
109 | + $argv['status'] = true; |
|
110 | 110 | } |
111 | - if ( array_key_exists ( 'update' , $argv ) ) |
|
111 | + if (array_key_exists('update', $argv)) |
|
112 | 112 | { |
113 | - die ( $this->update () ); |
|
113 | + die ($this->update()); |
|
114 | 114 | } |
115 | - if ( array_key_exists ( 'download' , $argv ) ) |
|
115 | + if (array_key_exists('download', $argv)) |
|
116 | 116 | { |
117 | - die ( $this->download ( $argv[ 'download' ] ) ); |
|
117 | + die ($this->download($argv['download'])); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | self::$version = Version::getVersion(); |
121 | - $this->argv = $this->parseConfig ( $basePath , $argv ); |
|
121 | + $this->argv = $this->parseConfig($basePath, $argv); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @return string |
128 | 128 | */ |
129 | - public function getUsage () |
|
129 | + public function getUsage() |
|
130 | 130 | { |
131 | 131 | $version = self::$version; |
132 | - $list = $this->renderParam (); |
|
132 | + $list = $this->renderParam(); |
|
133 | 133 | |
134 | 134 | return <<<EOF |
135 | 135 | parameters: |
@@ -140,12 +140,12 @@ discard block |
||
140 | 140 | EOF; |
141 | 141 | } |
142 | 142 | |
143 | - public function renderParam () |
|
143 | + public function renderParam() |
|
144 | 144 | { |
145 | 145 | $return = ""; |
146 | - foreach ( $this->parameterList as $param => $desc ) |
|
146 | + foreach ($this->parameterList as $param => $desc) |
|
147 | 147 | { |
148 | - if ( strlen ( $param ) < 5 ) |
|
148 | + if (strlen($param) < 5) |
|
149 | 149 | { |
150 | 150 | $return .= "\t--" . $param . "\t\t: " . $desc . "\n"; |
151 | 151 | } else |
@@ -158,21 +158,21 @@ discard block |
||
158 | 158 | return $return; |
159 | 159 | } |
160 | 160 | |
161 | - public function update () |
|
161 | + public function update() |
|
162 | 162 | { |
163 | 163 | $update = new Update(); |
164 | - $update->update () |
|
165 | - ->modifyTempName (); |
|
164 | + $update->update() |
|
165 | + ->modifyTempName(); |
|
166 | 166 | } |
167 | 167 | |
168 | - public function download ( $version ) |
|
168 | + public function download($version) |
|
169 | 169 | { |
170 | 170 | $update = new Update(); |
171 | - $update->downloadVersion ( $version ) |
|
172 | - ->modifyTempName (); |
|
171 | + $update->downloadVersion($version) |
|
172 | + ->modifyTempName(); |
|
173 | 173 | } |
174 | 174 | |
175 | - public function getVersion () |
|
175 | + public function getVersion() |
|
176 | 176 | { |
177 | 177 | $version = self::$version; |
178 | 178 | return "ORM Generator \nVersion: {$version}\ncreated by: Pedro Alarcao <https://github.com/pedro151/orm-generator>\n{$version->messageHasNewVersion()}"; |
@@ -187,31 +187,31 @@ discard block |
||
187 | 187 | * @return array |
188 | 188 | * @throws \Exception |
189 | 189 | */ |
190 | - private function parseConfig ( $basePath , $argv ) |
|
190 | + private function parseConfig($basePath, $argv) |
|
191 | 191 | { |
192 | 192 | $this->_basePath = $basePath; |
193 | 193 | |
194 | - $configIni = isset( $argv[ 'name-ini' ] ) |
|
195 | - ? $argv[ 'name-ini' ] |
|
194 | + $configIni = isset($argv['name-ini']) |
|
195 | + ? $argv['name-ini'] |
|
196 | 196 | : $this->_basePath |
197 | 197 | . $this->configIniDefault; |
198 | 198 | |
199 | - $configTemp = $this->loadIniFile ( realpath ( $configIni ) ); |
|
200 | - $configCurrent = self::parseConfigEnv ( $configTemp , $argv ); |
|
199 | + $configTemp = $this->loadIniFile(realpath($configIni)); |
|
200 | + $configCurrent = self::parseConfigEnv($configTemp, $argv); |
|
201 | 201 | |
202 | - if ( ! isset( $configCurrent[ 'framework' ] ) ) |
|
202 | + if ( ! isset($configCurrent['framework'])) |
|
203 | 203 | { |
204 | - throw new \Exception( "configure which framework you want to use! \n" ); |
|
204 | + throw new \Exception("configure which framework you want to use! \n"); |
|
205 | 205 | } |
206 | 206 | |
207 | - if ( ! in_array ( $configCurrent[ 'framework' ] , $this->frameworkList ) ) |
|
207 | + if ( ! in_array($configCurrent['framework'], $this->frameworkList)) |
|
208 | 208 | { |
209 | - $frameworks = implode ( "\n\t" , $this->frameworkList ); |
|
210 | - throw new \Exception( "list of frameworks: \n\t\033[1;33m" . $frameworks |
|
211 | - . "\n\033[0m" ); |
|
209 | + $frameworks = implode("\n\t", $this->frameworkList); |
|
210 | + throw new \Exception("list of frameworks: \n\t\033[1;33m" . $frameworks |
|
211 | + . "\n\033[0m"); |
|
212 | 212 | } |
213 | 213 | |
214 | - return $argv + array_filter ( $configCurrent ); |
|
214 | + return $argv + array_filter($configCurrent); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -221,24 +221,24 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return string |
223 | 223 | */ |
224 | - private static function parseConfigEnv ( $configTemp , $argv ) |
|
224 | + private static function parseConfigEnv($configTemp, $argv) |
|
225 | 225 | { |
226 | - $thisSection = isset( $configTemp[ key ( $configTemp ) ][ 'config-env' ] ) |
|
227 | - ? $configTemp[ key ( |
|
226 | + $thisSection = isset($configTemp[key($configTemp)]['config-env']) |
|
227 | + ? $configTemp[key( |
|
228 | 228 | $configTemp |
229 | - ) ][ 'config-env' ] : null; |
|
229 | + )]['config-env'] : null; |
|
230 | 230 | |
231 | - $thisSection = isset( $argv[ 'config-env' ] ) ? $argv[ 'config-env' ] |
|
231 | + $thisSection = isset($argv['config-env']) ? $argv['config-env'] |
|
232 | 232 | : $thisSection; |
233 | 233 | |
234 | - if ( isset( $configTemp[ $thisSection ][ 'extends' ] ) ) |
|
234 | + if (isset($configTemp[$thisSection]['extends'])) |
|
235 | 235 | { |
236 | 236 | #faz marge da config principal com a config extendida |
237 | - return $configTemp[ $thisSection ] |
|
238 | - + $configTemp[ $configTemp[ $thisSection ][ 'extends' ] ]; |
|
237 | + return $configTemp[$thisSection] |
|
238 | + + $configTemp[$configTemp[$thisSection]['extends']]; |
|
239 | 239 | } |
240 | 240 | |
241 | - return $configTemp[ key ( $configTemp ) ]; |
|
241 | + return $configTemp[key($configTemp)]; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -252,32 +252,32 @@ discard block |
||
252 | 252 | * @throws \Exception |
253 | 253 | * @return array |
254 | 254 | */ |
255 | - protected function loadIniFile ( $filename ) |
|
255 | + protected function loadIniFile($filename) |
|
256 | 256 | { |
257 | - if ( ! is_file ( $filename ) ) |
|
257 | + if ( ! is_file($filename)) |
|
258 | 258 | { |
259 | - throw new \Exception( "\033[0;31mError: configuration file does not exist! \033[0m\n" ); |
|
259 | + throw new \Exception("\033[0;31mError: configuration file does not exist! \033[0m\n"); |
|
260 | 260 | } |
261 | 261 | |
262 | - $loaded = parse_ini_file ( $filename , true ); |
|
263 | - $iniArray = array (); |
|
264 | - foreach ( $loaded as $key => $data ) |
|
262 | + $loaded = parse_ini_file($filename, true); |
|
263 | + $iniArray = array(); |
|
264 | + foreach ($loaded as $key => $data) |
|
265 | 265 | { |
266 | - $pieces = explode ( $this->sectionSeparator , $key ); |
|
267 | - $thisSection = trim ( $pieces[ 0 ] ); |
|
268 | - switch ( count ( $pieces ) ) |
|
266 | + $pieces = explode($this->sectionSeparator, $key); |
|
267 | + $thisSection = trim($pieces[0]); |
|
268 | + switch (count($pieces)) |
|
269 | 269 | { |
270 | 270 | case 1: |
271 | - $iniArray[ $thisSection ] = $data; |
|
271 | + $iniArray[$thisSection] = $data; |
|
272 | 272 | break; |
273 | 273 | |
274 | 274 | case 2: |
275 | - $extendedSection = trim ( $pieces[ 1 ] ); |
|
276 | - $iniArray[ $thisSection ] = array_merge ( array ( 'extends' => $extendedSection ) , $data ); |
|
275 | + $extendedSection = trim($pieces[1]); |
|
276 | + $iniArray[$thisSection] = array_merge(array('extends' => $extendedSection), $data); |
|
277 | 277 | break; |
278 | 278 | |
279 | 279 | default: |
280 | - throw new \Exception( "Section '$thisSection' may not extend multiple sections in $filename" ); |
|
280 | + throw new \Exception("Section '$thisSection' may not extend multiple sections in $filename"); |
|
281 | 281 | } |
282 | 282 | } |
283 | 283 | |
@@ -290,16 +290,16 @@ discard block |
||
290 | 290 | * @return \Classes\AdapterConfig\AbstractAdapter |
291 | 291 | * |
292 | 292 | */ |
293 | - private function factoryConfig () |
|
293 | + private function factoryConfig() |
|
294 | 294 | { |
295 | - switch ( strtolower ( $this->argv[ 'framework' ] ) ) |
|
295 | + switch (strtolower($this->argv['framework'])) |
|
296 | 296 | { |
297 | 297 | case 'zf1': |
298 | - return new ZendFrameworkOne( $this->argv ); |
|
298 | + return new ZendFrameworkOne($this->argv); |
|
299 | 299 | case 'phalcon': |
300 | - return new Phalcon( $this->argv ); |
|
300 | + return new Phalcon($this->argv); |
|
301 | 301 | default: |
302 | - return new None( $this->argv ); |
|
302 | + return new None($this->argv); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | } |
@@ -311,33 +311,33 @@ discard block |
||
311 | 311 | * |
312 | 312 | * @return AdaptersDriver\AbsractAdapter |
313 | 313 | */ |
314 | - private function factoryDriver ( AdapterConfig\AbstractAdapter $config ) |
|
314 | + private function factoryDriver(AdapterConfig\AbstractAdapter $config) |
|
315 | 315 | { |
316 | - switch ( $this->argv[ 'driver' ] ) |
|
316 | + switch ($this->argv['driver']) |
|
317 | 317 | { |
318 | 318 | case 'pgsql': |
319 | 319 | case 'pdo_pgsql': |
320 | - return new Pgsql( $config ); |
|
320 | + return new Pgsql($config); |
|
321 | 321 | case 'mysql': |
322 | 322 | case 'pdo_mysql': |
323 | - return new Mysql( $config ); |
|
323 | + return new Mysql($config); |
|
324 | 324 | case 'mssql': |
325 | - return new Mssql( $config ); |
|
325 | + return new Mssql($config); |
|
326 | 326 | case 'dblib': |
327 | - return new Dblib( $config ); |
|
327 | + return new Dblib($config); |
|
328 | 328 | case 'sqlsrv': |
329 | - return new Sqlsrv( $config ); |
|
329 | + return new Sqlsrv($config); |
|
330 | 330 | } |
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
334 | 334 | * @return AdapterConfig\AbstractAdapter |
335 | 335 | */ |
336 | - public function getAdapterConfig () |
|
336 | + public function getAdapterConfig() |
|
337 | 337 | { |
338 | - if ( ! $this->adapterConfig instanceof AbstractAdapter ) |
|
338 | + if ( ! $this->adapterConfig instanceof AbstractAdapter) |
|
339 | 339 | { |
340 | - $this->adapterConfig = $this->factoryConfig (); |
|
340 | + $this->adapterConfig = $this->factoryConfig(); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | return $this->adapterConfig; |
@@ -346,11 +346,11 @@ discard block |
||
346 | 346 | /** |
347 | 347 | * @return AdaptersDriver\AbsractAdapter |
348 | 348 | */ |
349 | - public function getAdapterDriver ( AdapterConfig\AbstractAdapter $config ) |
|
349 | + public function getAdapterDriver(AdapterConfig\AbstractAdapter $config) |
|
350 | 350 | { |
351 | - if ( ! $this->adapterDriver ) |
|
351 | + if ( ! $this->adapterDriver) |
|
352 | 352 | { |
353 | - $this->adapterDriver = $this->factoryDriver ( $config ); |
|
353 | + $this->adapterDriver = $this->factoryDriver($config); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | return $this->adapterDriver; |
@@ -16,101 +16,101 @@ discard block |
||
16 | 16 | abstract class AbstractAdapter |
17 | 17 | { |
18 | 18 | |
19 | - protected $arrConfig = array ( |
|
19 | + protected $arrConfig = array( |
|
20 | 20 | ############################# DATABASE |
21 | 21 | //Driver do banco de dados |
22 | - 'driver' => null , |
|
22 | + 'driver' => null, |
|
23 | 23 | //Nome do banco de dados |
24 | - 'database' => null , |
|
24 | + 'database' => null, |
|
25 | 25 | //Host do banco |
26 | - 'host' => 'localhost' , |
|
26 | + 'host' => 'localhost', |
|
27 | 27 | //Port do banco |
28 | - 'port' => '' , |
|
28 | + 'port' => '', |
|
29 | 29 | //usuario do banco |
30 | - 'username' => null , |
|
30 | + 'username' => null, |
|
31 | 31 | //senha do banco |
32 | - 'password' => null , |
|
32 | + 'password' => null, |
|
33 | 33 | // lista de schemas do banco de dados |
34 | - 'schema' => array () , |
|
35 | - 'version' => '' , |
|
36 | - 'socket' => null , |
|
34 | + 'schema' => array(), |
|
35 | + 'version' => '', |
|
36 | + 'socket' => null, |
|
37 | 37 | |
38 | 38 | ########################### DOCS |
39 | 39 | // autor que gerou o script |
40 | - 'author' => "Pedro" , |
|
41 | - 'license' => "New BSD License" , |
|
42 | - 'copyright' => "ORM Generator - Pedro151" , |
|
43 | - 'link' => 'https://github.com/pedro151/orm-generator' , |
|
44 | - 'version' => '' , |
|
40 | + 'author' => "Pedro", |
|
41 | + 'license' => "New BSD License", |
|
42 | + 'copyright' => "ORM Generator - Pedro151", |
|
43 | + 'link' => 'https://github.com/pedro151/orm-generator', |
|
44 | + 'version' => '', |
|
45 | 45 | // data que foi gerado o script |
46 | - 'last_modify' => null , |
|
46 | + 'last_modify' => null, |
|
47 | 47 | |
48 | 48 | ########################## Ambiente/Arquivos |
49 | 49 | |
50 | 50 | // Nome do framework para o adapter |
51 | - 'framework' => null , |
|
51 | + 'framework' => null, |
|
52 | 52 | // namespace das classes |
53 | - 'namespace' => "" , |
|
53 | + 'namespace' => "", |
|
54 | 54 | // caminho onde os arquivos devem ser criados |
55 | - 'path' => 'models' , |
|
55 | + 'path' => 'models', |
|
56 | 56 | // flag para gerar pasta com o nome do driver do banco de dados |
57 | - 'folder-database' => 0 , |
|
57 | + 'folder-database' => 0, |
|
58 | 58 | // string com o nome da pastar personalizada |
59 | - 'folder-name' => '' , |
|
59 | + 'folder-name' => '', |
|
60 | 60 | |
61 | 61 | 'clean-trash' => false, |
62 | 62 | |
63 | 63 | ############################## Comandos adicionais |
64 | 64 | //flag para mostrar o status da execução ao termino do processo |
65 | - 'status' => false , |
|
65 | + 'status' => false, |
|
66 | 66 | // flags para criar todas as tabelas ou nao |
67 | - 'tables' => array () , |
|
67 | + 'tables' => array(), |
|
68 | 68 | // lista de Classes opcionais pre-definidas para serem criadas |
69 | - 'optional-classes'=> array (), |
|
69 | + 'optional-classes'=> array(), |
|
70 | 70 | //Lista de tabelas a serem ignoradas |
71 | - 'ignoreTable' => array () , |
|
71 | + 'ignoreTable' => array(), |
|
72 | 72 | ); |
73 | 73 | |
74 | 74 | /** |
75 | 75 | * @var string[] um array com todos os campos obrigatorios |
76 | 76 | */ |
77 | - protected $attRequered = array ( |
|
78 | - 'driver' => true , |
|
79 | - 'database' => true , |
|
80 | - 'host' => true , |
|
81 | - 'username' => true , |
|
77 | + protected $attRequered = array( |
|
78 | + 'driver' => true, |
|
79 | + 'database' => true, |
|
80 | + 'host' => true, |
|
81 | + 'username' => true, |
|
82 | 82 | 'path' => true |
83 | 83 | ); |
84 | 84 | |
85 | - protected $arrFunc = array (); |
|
85 | + protected $arrFunc = array(); |
|
86 | 86 | |
87 | - private $framworkFiles = array (); |
|
87 | + private $framworkFiles = array(); |
|
88 | 88 | |
89 | - public $reservedWord = array (); |
|
89 | + public $reservedWord = array(); |
|
90 | 90 | |
91 | - private static $dataTypesDefault = array ( |
|
92 | - 'int' => 'int' , |
|
93 | - 'float' => 'float' , |
|
94 | - 'string' => 'string' , |
|
95 | - 'text' => 'string' , |
|
96 | - 'date' => 'date' , |
|
97 | - 'datetime' => 'datetime' , |
|
98 | - 'timestamp' => 'timestamp' , |
|
91 | + private static $dataTypesDefault = array( |
|
92 | + 'int' => 'int', |
|
93 | + 'float' => 'float', |
|
94 | + 'string' => 'string', |
|
95 | + 'text' => 'string', |
|
96 | + 'date' => 'date', |
|
97 | + 'datetime' => 'datetime', |
|
98 | + 'timestamp' => 'timestamp', |
|
99 | 99 | 'boolean' => 'boolean' |
100 | 100 | ); |
101 | 101 | |
102 | - private static $dataTypesPhp = array ( |
|
103 | - 'int' => 'int' , |
|
104 | - 'float' => 'float' , |
|
105 | - 'string' => 'string' , |
|
106 | - 'text' => 'string' , |
|
107 | - 'date' => 'string' , |
|
108 | - 'datetime' => 'string' , |
|
109 | - 'timestamp' => 'string' , |
|
102 | + private static $dataTypesPhp = array( |
|
103 | + 'int' => 'int', |
|
104 | + 'float' => 'float', |
|
105 | + 'string' => 'string', |
|
106 | + 'text' => 'string', |
|
107 | + 'date' => 'string', |
|
108 | + 'datetime' => 'string', |
|
109 | + 'timestamp' => 'string', |
|
110 | 110 | 'boolean' => 'boolean' |
111 | 111 | ); |
112 | 112 | |
113 | - protected $dataTypes = array (); |
|
113 | + protected $dataTypes = array(); |
|
114 | 114 | |
115 | 115 | const SEPARETOR = ""; |
116 | 116 | |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @return bool |
121 | 121 | */ |
122 | - protected function checkConfig () |
|
122 | + protected function checkConfig() |
|
123 | 123 | { |
124 | - if ( array_diff_key ( $this->attRequered , array_filter ( $this->arrConfig ) ) ) |
|
124 | + if (array_diff_key($this->attRequered, array_filter($this->arrConfig))) |
|
125 | 125 | { |
126 | 126 | return false; |
127 | 127 | } |
@@ -134,33 +134,33 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @return array |
136 | 136 | */ |
137 | - abstract protected function getParams (); |
|
137 | + abstract protected function getParams(); |
|
138 | 138 | |
139 | 139 | /** |
140 | 140 | * Popula as config do generater com as configuraçoes do framework |
141 | 141 | * |
142 | 142 | * @return mixed |
143 | 143 | */ |
144 | - abstract protected function parseFrameworkConfig (); |
|
144 | + abstract protected function parseFrameworkConfig(); |
|
145 | 145 | |
146 | 146 | /** |
147 | 147 | * Cria Instancias dos arquivos que devem ser gerados |
148 | 148 | * |
149 | 149 | * @return \Classes\AdapterMakerFile\AbstractAdapter[] |
150 | 150 | */ |
151 | - abstract public function getMakeFileInstances (); |
|
151 | + abstract public function getMakeFileInstances(); |
|
152 | 152 | |
153 | - abstract protected function init (); |
|
153 | + abstract protected function init(); |
|
154 | 154 | |
155 | 155 | /** |
156 | 156 | * retorna a base do Namespace |
157 | 157 | * |
158 | 158 | * @return array |
159 | 159 | */ |
160 | - protected function getBaseNamespace () |
|
160 | + protected function getBaseNamespace() |
|
161 | 161 | { |
162 | - return array ( |
|
163 | - $this->arrConfig[ 'namespace' ] , |
|
162 | + return array( |
|
163 | + $this->arrConfig['namespace'], |
|
164 | 164 | 'Model' |
165 | 165 | ); |
166 | 166 | } |
@@ -171,54 +171,54 @@ discard block |
||
171 | 171 | * @return mixed |
172 | 172 | */ |
173 | 173 | |
174 | - public function createClassNamespace ( $table ) |
|
174 | + public function createClassNamespace($table) |
|
175 | 175 | { |
176 | - $arrNames = $this->getBaseNamespace (); |
|
176 | + $arrNames = $this->getBaseNamespace(); |
|
177 | 177 | |
178 | - if ( isset( $this->arrConfig[ 'folder-database' ] ) |
|
179 | - && $this->arrConfig[ 'folder-database' ] |
|
178 | + if (isset($this->arrConfig['folder-database']) |
|
179 | + && $this->arrConfig['folder-database'] |
|
180 | 180 | ) |
181 | 181 | { |
182 | - $arrNames[] = AbstractMaker::getClassName ( $this->arrConfig[ 'driver' ] ); |
|
182 | + $arrNames[] = AbstractMaker::getClassName($this->arrConfig['driver']); |
|
183 | 183 | } |
184 | 184 | |
185 | - if ( isset( $this->arrConfig[ 'folder-name' ] ) |
|
186 | - && $this->arrConfig[ 'folder-name' ] |
|
185 | + if (isset($this->arrConfig['folder-name']) |
|
186 | + && $this->arrConfig['folder-name'] |
|
187 | 187 | ) |
188 | 188 | { |
189 | - $arrNames[] = AbstractMaker::getClassName ( $this->arrConfig[ 'folder-name' ] ); |
|
189 | + $arrNames[] = AbstractMaker::getClassName($this->arrConfig['folder-name']); |
|
190 | 190 | } |
191 | 191 | |
192 | - if ( $table->hasSchema () ) |
|
192 | + if ($table->hasSchema()) |
|
193 | 193 | { |
194 | - $arrNames[] = $this->replaceReservedWord ( AbstractMaker::getClassName ( $table->getSchema () ) ); |
|
194 | + $arrNames[] = $this->replaceReservedWord(AbstractMaker::getClassName($table->getSchema())); |
|
195 | 195 | } else |
196 | 196 | { |
197 | - $arrNames[] = $this->replaceReservedWord ( AbstractMaker::getClassName ( $table->getDatabase () ) ); |
|
197 | + $arrNames[] = $this->replaceReservedWord(AbstractMaker::getClassName($table->getDatabase())); |
|
198 | 198 | } |
199 | 199 | |
200 | - return implode ( static::SEPARETOR , array_filter ( $arrNames ) ); |
|
200 | + return implode(static::SEPARETOR, array_filter($arrNames)); |
|
201 | 201 | } |
202 | 202 | |
203 | - public function __construct ( $array ) |
|
203 | + public function __construct($array) |
|
204 | 204 | { |
205 | 205 | $this->dataTypes = $this->dataTypes + self::$dataTypesDefault; |
206 | - $array += array ( |
|
207 | - 'version' => Config::$version , |
|
208 | - 'author' => ucfirst ( get_current_user () ) , |
|
209 | - 'last_modify' => date ( "d-m-Y" ) |
|
206 | + $array += array( |
|
207 | + 'version' => Config::$version, |
|
208 | + 'author' => ucfirst(get_current_user()), |
|
209 | + 'last_modify' => date("d-m-Y") |
|
210 | 210 | ); |
211 | 211 | |
212 | - $this->setFrameworkFiles ( $array ); |
|
213 | - $this->parseFrameworkConfig (); |
|
214 | - $this->setParams ( $this->getParams () ); |
|
215 | - $this->setParams ( $array ); |
|
216 | - $this->init (); |
|
217 | - $this->validTableNames (); |
|
218 | - if ( ! $this->isValid () ) |
|
212 | + $this->setFrameworkFiles($array); |
|
213 | + $this->parseFrameworkConfig(); |
|
214 | + $this->setParams($this->getParams()); |
|
215 | + $this->setParams($array); |
|
216 | + $this->init(); |
|
217 | + $this->validTableNames(); |
|
218 | + if ( ! $this->isValid()) |
|
219 | 219 | { |
220 | - $var = array_diff_key ( $this->attRequered , array_filter ( $this->arrConfig ) ); |
|
221 | - throw new Exception( $var ); |
|
220 | + $var = array_diff_key($this->attRequered, array_filter($this->arrConfig)); |
|
221 | + throw new Exception($var); |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 | |
@@ -227,43 +227,43 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @param $array |
229 | 229 | */ |
230 | - public function setFrameworkFiles ( $array ) |
|
230 | + public function setFrameworkFiles($array) |
|
231 | 231 | { |
232 | - $this->framworkFiles[ 'library' ] = isset( $array[ 'framework-path-library' ] ) |
|
233 | - ? $array[ 'framework-path-library' ] : null; |
|
232 | + $this->framworkFiles['library'] = isset($array['framework-path-library']) |
|
233 | + ? $array['framework-path-library'] : null; |
|
234 | 234 | |
235 | - $this->framworkFiles[ 'ini' ] = isset( $array[ 'framework-ini' ] ) |
|
236 | - ? $array[ 'framework-ini' ] : null; |
|
235 | + $this->framworkFiles['ini'] = isset($array['framework-ini']) |
|
236 | + ? $array['framework-ini'] : null; |
|
237 | 237 | |
238 | - $this->framworkFiles[ 'environment' ] = isset( $array[ 'environment' ] ) |
|
239 | - ? $array[ 'environment' ] : 'production'; |
|
238 | + $this->framworkFiles['environment'] = isset($array['environment']) |
|
239 | + ? $array['environment'] : 'production'; |
|
240 | 240 | |
241 | 241 | } |
242 | 242 | |
243 | - protected function isValidFrameworkFiles () |
|
243 | + protected function isValidFrameworkFiles() |
|
244 | 244 | { |
245 | - if ( ! is_file ( $this->framworkFiles[ 'ini' ] ) ) |
|
245 | + if ( ! is_file($this->framworkFiles['ini'])) |
|
246 | 246 | { |
247 | 247 | return false; |
248 | 248 | } |
249 | 249 | |
250 | - if ( ! is_dir ( $this->framworkFiles[ 'library' ] ) ) |
|
250 | + if ( ! is_dir($this->framworkFiles['library'])) |
|
251 | 251 | { |
252 | 252 | return false; |
253 | 253 | } |
254 | 254 | |
255 | - if ( ! isset ( $this->framworkFiles[ 'environment' ] ) |
|
256 | - or empty( $this->framworkFiles[ 'environment' ] ) |
|
255 | + if ( ! isset ($this->framworkFiles['environment']) |
|
256 | + or empty($this->framworkFiles['environment']) |
|
257 | 257 | ) |
258 | 258 | { |
259 | 259 | return false; |
260 | 260 | } |
261 | - set_include_path ( |
|
262 | - implode ( |
|
263 | - PATH_SEPARATOR , |
|
264 | - array ( |
|
265 | - realpath ( $this->framworkFiles[ 'library' ] ) , |
|
266 | - get_include_path () , |
|
261 | + set_include_path( |
|
262 | + implode( |
|
263 | + PATH_SEPARATOR, |
|
264 | + array( |
|
265 | + realpath($this->framworkFiles['library']), |
|
266 | + get_include_path(), |
|
267 | 267 | ) |
268 | 268 | ) |
269 | 269 | ); |
@@ -271,119 +271,119 @@ discard block |
||
271 | 271 | return true; |
272 | 272 | } |
273 | 273 | |
274 | - protected function getFrameworkIni () |
|
274 | + protected function getFrameworkIni() |
|
275 | 275 | { |
276 | - return $this->framworkFiles[ 'ini' ]; |
|
276 | + return $this->framworkFiles['ini']; |
|
277 | 277 | } |
278 | 278 | |
279 | - protected function getEnvironment () |
|
279 | + protected function getEnvironment() |
|
280 | 280 | { |
281 | - return $this->framworkFiles[ 'environment' ]; |
|
281 | + return $this->framworkFiles['environment']; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
285 | 285 | * Popula as variaveis de acordo com o arquivo de configuração do seu framework |
286 | 286 | */ |
287 | - protected function isValid () |
|
287 | + protected function isValid() |
|
288 | 288 | { |
289 | - return $this->checkConfig (); |
|
289 | + return $this->checkConfig(); |
|
290 | 290 | } |
291 | 291 | |
292 | - private function setParams ( $array ) |
|
292 | + private function setParams($array) |
|
293 | 293 | { |
294 | - if ( count ( $array ) > 0 ) |
|
294 | + if (count($array) > 0) |
|
295 | 295 | { |
296 | - $this->arrConfig = array_filter ( $array ) + $this->arrConfig; |
|
296 | + $this->arrConfig = array_filter($array) + $this->arrConfig; |
|
297 | 297 | } |
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
301 | 301 | * @return string |
302 | 302 | */ |
303 | - public function getDatabase () |
|
303 | + public function getDatabase() |
|
304 | 304 | { |
305 | - return $this->arrConfig[ 'database' ]; |
|
305 | + return $this->arrConfig['database']; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
309 | 309 | * @return bool |
310 | 310 | */ |
311 | - public function hasSchemas () |
|
311 | + public function hasSchemas() |
|
312 | 312 | { |
313 | - return ! empty ( $this->arrConfig[ 'schema' ] ); |
|
313 | + return ! empty ($this->arrConfig['schema']); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
317 | 317 | * @return string[] |
318 | 318 | */ |
319 | - public function getSchemas () |
|
319 | + public function getSchemas() |
|
320 | 320 | { |
321 | - if ( is_string ( $this->arrConfig[ 'schema' ] ) ) |
|
321 | + if (is_string($this->arrConfig['schema'])) |
|
322 | 322 | { |
323 | - return array ( $this->arrConfig[ 'schema' ] ); |
|
323 | + return array($this->arrConfig['schema']); |
|
324 | 324 | } |
325 | 325 | |
326 | - return $this->arrConfig[ 'schema' ]; |
|
326 | + return $this->arrConfig['schema']; |
|
327 | 327 | } |
328 | 328 | |
329 | - public function setSchema ( $schema ) |
|
329 | + public function setSchema($schema) |
|
330 | 330 | { |
331 | - $this->arrConfig[ 'schema' ] = $schema; |
|
331 | + $this->arrConfig['schema'] = $schema; |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
335 | 335 | * @return string |
336 | 336 | */ |
337 | - public function getHost () |
|
337 | + public function getHost() |
|
338 | 338 | { |
339 | - return $this->arrConfig[ 'host' ]; |
|
339 | + return $this->arrConfig['host']; |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | /** |
343 | 343 | * @return int |
344 | 344 | */ |
345 | - public function getPort () |
|
345 | + public function getPort() |
|
346 | 346 | { |
347 | - return $this->arrConfig[ 'port' ]; |
|
347 | + return $this->arrConfig['port']; |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
351 | 351 | * @return boolean |
352 | 352 | */ |
353 | - public function hasPort () |
|
353 | + public function hasPort() |
|
354 | 354 | { |
355 | - return ! empty( $this->arrConfig[ 'port' ] ); |
|
355 | + return ! empty($this->arrConfig['port']); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
359 | 359 | * @return boolean |
360 | 360 | */ |
361 | - public function isCleanTrash(){ |
|
362 | - return (boolean) $this->arrConfig[ 'clean-trash' ]; |
|
361 | + public function isCleanTrash() { |
|
362 | + return (boolean) $this->arrConfig['clean-trash']; |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | /** |
366 | 366 | * @return string |
367 | 367 | */ |
368 | - public function getSocket () |
|
368 | + public function getSocket() |
|
369 | 369 | { |
370 | - return $this->arrConfig[ 'socket' ]; |
|
370 | + return $this->arrConfig['socket']; |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
374 | 374 | * @return string |
375 | 375 | */ |
376 | - public function getUser () |
|
376 | + public function getUser() |
|
377 | 377 | { |
378 | - return $this->arrConfig[ 'username' ]; |
|
378 | + return $this->arrConfig['username']; |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | /** |
382 | 382 | * @return string |
383 | 383 | */ |
384 | - public function getPassword () |
|
384 | + public function getPassword() |
|
385 | 385 | { |
386 | - return $this->arrConfig[ 'password' ]; |
|
386 | + return $this->arrConfig['password']; |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | /** |
@@ -391,11 +391,11 @@ discard block |
||
391 | 391 | * |
392 | 392 | * @return string |
393 | 393 | */ |
394 | - public function replaceReservedWord ( $palavra ) |
|
394 | + public function replaceReservedWord($palavra) |
|
395 | 395 | { |
396 | - if ( isset( $this->reservedWord[ strtolower ( $palavra ) ] ) ) |
|
396 | + if (isset($this->reservedWord[strtolower($palavra)])) |
|
397 | 397 | { |
398 | - return $this->reservedWord[ strtolower ( $palavra ) ]; |
|
398 | + return $this->reservedWord[strtolower($palavra)]; |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | return $palavra; |
@@ -404,15 +404,15 @@ discard block |
||
404 | 404 | /** |
405 | 405 | * @return bool |
406 | 406 | */ |
407 | - public function isStatusEnabled () |
|
407 | + public function isStatusEnabled() |
|
408 | 408 | { |
409 | - return (bool) $this->arrConfig[ 'status' ]; |
|
409 | + return (bool) $this->arrConfig['status']; |
|
410 | 410 | } |
411 | 411 | |
412 | - public function validTableNames () |
|
412 | + public function validTableNames() |
|
413 | 413 | { |
414 | - $matches = preg_grep ( '*\.*' , $this->getTablesName () ); |
|
415 | - if ( count ( $matches ) ) |
|
414 | + $matches = preg_grep('*\.*', $this->getTablesName()); |
|
415 | + if (count($matches)) |
|
416 | 416 | { |
417 | 417 | die("\033[0;31mError: Table name must not contain the schema.\033[0m\n"); |
418 | 418 | } |
@@ -421,49 +421,49 @@ discard block |
||
421 | 421 | /** |
422 | 422 | * @return bool |
423 | 423 | */ |
424 | - public function hasTablesName (){ |
|
425 | - return ! empty( $this->arrConfig[ 'tables' ] ); |
|
424 | + public function hasTablesName() { |
|
425 | + return ! empty($this->arrConfig['tables']); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | /** |
429 | 429 | * @return string[] |
430 | 430 | */ |
431 | - public function getTablesName () |
|
431 | + public function getTablesName() |
|
432 | 432 | { |
433 | - if ( is_string ( $this->arrConfig[ 'tables' ] ) ) |
|
433 | + if (is_string($this->arrConfig['tables'])) |
|
434 | 434 | { |
435 | - return array ( $this->arrConfig[ 'tables' ] ); |
|
435 | + return array($this->arrConfig['tables']); |
|
436 | 436 | } |
437 | 437 | |
438 | - return $this->arrConfig[ 'tables' ]; |
|
438 | + return $this->arrConfig['tables']; |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | /** |
442 | 442 | * @return string |
443 | 443 | */ |
444 | - public function getListTablesName(){ |
|
445 | - $str = implode("','", $this->getTablesName() ); |
|
444 | + public function getListTablesName() { |
|
445 | + $str = implode("','", $this->getTablesName()); |
|
446 | 446 | return "'$str'"; |
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
450 | 450 | * @return bool |
451 | 451 | */ |
452 | - public function hasOptionalClasses (){ |
|
453 | - return ! empty( $this->arrConfig[ 'optional-classes' ] ); |
|
452 | + public function hasOptionalClasses() { |
|
453 | + return ! empty($this->arrConfig['optional-classes']); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | /** |
457 | 457 | * @return string[] |
458 | 458 | */ |
459 | - public function getOptionalClasses () |
|
459 | + public function getOptionalClasses() |
|
460 | 460 | { |
461 | - if ( is_string ( $this->arrConfig[ 'optional-classes' ] ) ) |
|
461 | + if (is_string($this->arrConfig['optional-classes'])) |
|
462 | 462 | { |
463 | - return array ( $this->arrConfig[ 'optional-classes' ] ); |
|
463 | + return array($this->arrConfig['optional-classes']); |
|
464 | 464 | } |
465 | 465 | |
466 | - return $this->arrConfig[ 'optional-classes' ]; |
|
466 | + return $this->arrConfig['optional-classes']; |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | /** |
@@ -471,25 +471,25 @@ discard block |
||
471 | 471 | * |
472 | 472 | * @return string |
473 | 473 | */ |
474 | - public function __get ( $str ) |
|
474 | + public function __get($str) |
|
475 | 475 | { |
476 | - $arr = array ( |
|
477 | - 'namespace' , |
|
478 | - 'framework' , |
|
479 | - 'author' , |
|
480 | - 'license' , |
|
481 | - 'version' , |
|
482 | - 'copyright' , |
|
483 | - 'link' , |
|
484 | - 'last_modify' , |
|
485 | - 'path' , |
|
486 | - 'folder-database' , |
|
476 | + $arr = array( |
|
477 | + 'namespace', |
|
478 | + 'framework', |
|
479 | + 'author', |
|
480 | + 'license', |
|
481 | + 'version', |
|
482 | + 'copyright', |
|
483 | + 'link', |
|
484 | + 'last_modify', |
|
485 | + 'path', |
|
486 | + 'folder-database', |
|
487 | 487 | 'folder-name' |
488 | 488 | ); |
489 | 489 | |
490 | - if ( in_array ( $str , $arr ) ) |
|
490 | + if (in_array($str, $arr)) |
|
491 | 491 | { |
492 | - return $this->arrConfig[ strtolower ( $str ) ]; |
|
492 | + return $this->arrConfig[strtolower($str)]; |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | return; |
@@ -500,9 +500,9 @@ discard block |
||
500 | 500 | * |
501 | 501 | * @return string |
502 | 502 | */ |
503 | - public static function convertTypeToPHP ( $type ) |
|
503 | + public static function convertTypeToPHP($type) |
|
504 | 504 | { |
505 | - return self::$dataTypesPhp[ $type ]; |
|
505 | + return self::$dataTypesPhp[$type]; |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
@@ -510,9 +510,9 @@ discard block |
||
510 | 510 | * |
511 | 511 | * @return string |
512 | 512 | */ |
513 | - public static function convertTypeToDefault ( $type ) |
|
513 | + public static function convertTypeToDefault($type) |
|
514 | 514 | { |
515 | - return self::$dataTypesDefault[ $type ]; |
|
515 | + return self::$dataTypesDefault[$type]; |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | /** |
@@ -520,8 +520,8 @@ discard block |
||
520 | 520 | * |
521 | 521 | * @return string |
522 | 522 | */ |
523 | - public function convertTypeToTypeFramework ( $type ) |
|
523 | + public function convertTypeToTypeFramework($type) |
|
524 | 524 | { |
525 | - return $this->dataTypes[ $type ]; |
|
525 | + return $this->dataTypes[$type]; |
|
526 | 526 | } |
527 | 527 | } |
@@ -3,43 +3,43 @@ discard block |
||
3 | 3 | /** |
4 | 4 | * Mvc Model |
5 | 5 | * |
6 | - * <?=$this->config->last_modify."\n"?> |
|
6 | + * <?=$this->config->last_modify . "\n"?> |
|
7 | 7 | * |
8 | 8 | * @package <?=$objTables->getNamespace()?>\Entity |
9 | 9 | * @subpackage Model |
10 | - * @author <?=$this->config->author."\n"?> |
|
10 | + * @author <?=$this->config->author . "\n"?> |
|
11 | 11 | * |
12 | - * @copyright <?=$this->config->copyright."\n"?> |
|
13 | - * @license <?=$this->config->license."\n"?> |
|
14 | - * @link <?=$this->config->link."\n"?> |
|
15 | - * @version <?=$this->config->version."\n"?> |
|
12 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
13 | + * @license <?=$this->config->license . "\n"?> |
|
14 | + * @link <?=$this->config->link . "\n"?> |
|
15 | + * @version <?=$this->config->version . "\n"?> |
|
16 | 16 | */ |
17 | 17 | |
18 | 18 | namespace <?=$objTables->getNamespace()?>\Entity; |
19 | 19 | |
20 | 20 | use Phalcon\Validation; |
21 | 21 | |
22 | -abstract class <?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?> extends \<?=$this->config->namespace?$this->config->namespace."\\":""?>Models\<?=$objMakeFile->getFilesFixeds('parentClass')->getFileName() . "\n"?> |
|
22 | +abstract class <?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?> extends \<?=$this->config->namespace ? $this->config->namespace . "\\" : ""?>Models\<?=$objMakeFile->getFilesFixeds('parentClass')->getFileName() . "\n"?> |
|
23 | 23 | { |
24 | 24 | |
25 | 25 | <?php foreach ($objTables->getColumns() as $column): ?> |
26 | 26 | /** |
27 | - * column <?=$column->getName()."\n"?> |
|
27 | + * column <?=$column->getName() . "\n"?> |
|
28 | 28 | * |
29 | -<?php if($column->isPrimaryKey()):?> |
|
29 | +<?php if ($column->isPrimaryKey()):?> |
|
30 | 30 | * @Primary |
31 | 31 | <?php endif ?> |
32 | -<?php if($column->hasSequence()):?> |
|
32 | +<?php if ($column->hasSequence()):?> |
|
33 | 33 | * @Identity |
34 | 34 | <?php endif ?> |
35 | - * @Column(type="<?=$column->getTypeByConfig( $this->config )?>", nullable=<?=($column->isNullable () or $column->hasColumnDefault()) ? "true" : "false"?><?php |
|
36 | -if ( $column->getMaxLength () ): ?> |
|
37 | -, length=<?=$column->getMaxLength ()?> |
|
35 | + * @Column(type="<?=$column->getTypeByConfig($this->config)?>", nullable=<?=($column->isNullable() or $column->hasColumnDefault()) ? "true" : "false"?><?php |
|
36 | +if ($column->getMaxLength()): ?> |
|
37 | +, length=<?=$column->getMaxLength()?> |
|
38 | 38 | <?php endif ?>, column="<?=$column->getName()?>" ) |
39 | 39 | */ |
40 | 40 | protected $<?=$column->getName()?>; |
41 | 41 | |
42 | -<?php endforeach;?> |
|
42 | +<?php endforeach; ?> |
|
43 | 43 | /** |
44 | 44 | * Validations and business logic |
45 | 45 | * |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | $validator = new Validation(); |
51 | 51 | |
52 | 52 | <?php foreach ($objTables->getColumns() as $column): ?> |
53 | -<?php if(strtolower($column->getName()) == 'email'):?> |
|
53 | +<?php if (strtolower($column->getName()) == 'email'):?> |
|
54 | 54 | $validator->add( |
55 | 55 | 'email', |
56 | 56 | new \Phalcon\Validation\Validator\Email() |
57 | 57 | ); |
58 | 58 | |
59 | 59 | <?php endif ?> |
60 | -<?php endforeach;?> |
|
60 | +<?php endforeach; ?> |
|
61 | 61 | return $this->validate($validator); |
62 | 62 | } |
63 | 63 | |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function initialize() |
68 | 68 | { |
69 | - <?=$mapDependents."\n"?> |
|
70 | - <?=$mapParents."\n"?> |
|
69 | + <?=$mapDependents . "\n"?> |
|
70 | + <?=$mapParents . "\n"?> |
|
71 | 71 | } |
72 | 72 | |
73 | -<?php if($objTables->hasSchema()): ?> |
|
73 | +<?php if ($objTables->hasSchema()): ?> |
|
74 | 74 | /** |
75 | 75 | * Returns schema name where table mapped is located |
76 | 76 | * |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | return '<?=$objTables->getName()?>'; |
93 | 93 | } |
94 | 94 | |
95 | -<?php if( $objTables->hasSequences() ) : ?> |
|
95 | +<?php if ($objTables->hasSequences()) : ?> |
|
96 | 96 | public function getSequenceName() |
97 | 97 | { |
98 | -<?php if ( 1 == count($objTables->getSequences() ) ) : ?> |
|
99 | - <?php $seqs = $objTables->getSequences();reset($seqs);$seq = current($seqs);?> |
|
98 | +<?php if (1 == count($objTables->getSequences())) : ?> |
|
99 | + <?php $seqs = $objTables->getSequences(); reset($seqs); $seq = current($seqs); ?> |
|
100 | 100 | return "<?=$seq->getSequence() ?>"; |
101 | 101 | <?php endif ?> |
102 | 102 | } |
@@ -104,9 +104,9 @@ discard block |
||
104 | 104 | <?php endif ?> |
105 | 105 | <?php foreach ($objTables->getColumns() as $column): ?> |
106 | 106 | /** |
107 | - * @return <?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () ) . "\n" ?> |
|
107 | + * @return <?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName()) . "\n" ?> |
|
108 | 108 | */ |
109 | - public function set<?=$this->getClassName ( $column->getName () )?>( $<?=$column->getName()?> ) |
|
109 | + public function set<?=$this->getClassName($column->getName())?>( $<?=$column->getName()?> ) |
|
110 | 110 | { |
111 | 111 | $this-><?=$column->getName()?> = $<?=$column->getName()?>; |
112 | 112 | |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
117 | - * @return <?=$column->getType ( \Classes\Db\Column::TypePHP )."\n" ?> |
|
117 | + * @return <?=$column->getType(\Classes\Db\Column::TypePHP) . "\n" ?> |
|
118 | 118 | **/ |
119 | - public function get<?=$this->getClassName ( $column->getName () )?>() |
|
119 | + public function get<?=$this->getClassName($column->getName())?>() |
|
120 | 120 | { |
121 | - return (<?=$column->getType ( \Classes\Db\Column::TypePHP )?>) $this-><?=$column->getName()?>; |
|
121 | + return (<?=$column->getType(\Classes\Db\Column::TypePHP)?>) $this-><?=$column->getName()?>; |
|
122 | 122 | } |
123 | -<?php endforeach;?> |
|
123 | +<?php endforeach; ?> |
|
124 | 124 | } |
125 | 125 | \ No newline at end of file |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | /** |
68 | 68 | * @type \Classes\Db\Iterators\DbTables[] |
69 | 69 | */ |
70 | - private $objDbTables = array (); |
|
70 | + private $objDbTables = array(); |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * @var AbstractAdapter |
@@ -82,22 +82,22 @@ discard block |
||
82 | 82 | /** |
83 | 83 | * analisa e popula as Foreing keys, Primary keys e dependencias do banco nos objetos |
84 | 84 | */ |
85 | - protected function parseConstrants () |
|
85 | + protected function parseConstrants() |
|
86 | 86 | { |
87 | - foreach ( $this->getListConstrant () as $constrant ) |
|
87 | + foreach ($this->getListConstrant() as $constrant) |
|
88 | 88 | { |
89 | 89 | |
90 | - $schema = $constrant[ 'table_schema' ]; |
|
91 | - $table_name = $constrant [ 'table_name' ]; |
|
92 | - $this->populateForeignAndPrimaryKeys ( $constrant , $table_name , $schema ); |
|
93 | - unset( $table_name , $schema ); |
|
90 | + $schema = $constrant['table_schema']; |
|
91 | + $table_name = $constrant ['table_name']; |
|
92 | + $this->populateForeignAndPrimaryKeys($constrant, $table_name, $schema); |
|
93 | + unset($table_name, $schema); |
|
94 | 94 | |
95 | - if ( $constrant[ 'constraint_type' ] == "FOREIGN KEY" ) |
|
95 | + if ($constrant['constraint_type'] == "FOREIGN KEY") |
|
96 | 96 | { |
97 | - $schema = $constrant[ 'foreign_schema' ]; |
|
98 | - $table_name = $constrant [ 'foreign_table' ]; |
|
99 | - $this->populateDependece ( $constrant , $table_name , $schema ); |
|
100 | - unset( $table_name , $schema ); |
|
97 | + $schema = $constrant['foreign_schema']; |
|
98 | + $table_name = $constrant ['foreign_table']; |
|
99 | + $this->populateDependece($constrant, $table_name, $schema); |
|
100 | + unset($table_name, $schema); |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | } |
@@ -107,37 +107,37 @@ discard block |
||
107 | 107 | * @param string $table_name |
108 | 108 | * @param int $schema |
109 | 109 | */ |
110 | - private function populateForeignAndPrimaryKeys ( $constrant , $table_name , $schema = 0 ) |
|
110 | + private function populateForeignAndPrimaryKeys($constrant, $table_name, $schema = 0) |
|
111 | 111 | { |
112 | - if ( $this->hasTable ( $table_name , $schema ) ) |
|
112 | + if ($this->hasTable($table_name, $schema)) |
|
113 | 113 | { |
114 | - $table = $this->getTable ( $table_name , $schema ); |
|
115 | - if ( $table->hasColumn ( $constrant[ "column_name" ] ) ) |
|
114 | + $table = $this->getTable($table_name, $schema); |
|
115 | + if ($table->hasColumn($constrant["column_name"])) |
|
116 | 116 | { |
117 | - $objConstrant = Constrant::getInstance () |
|
118 | - ->populate ( |
|
119 | - array ( |
|
120 | - 'constrant' => $constrant[ 'constraint_name' ] , |
|
121 | - 'schema' => $constrant[ 'foreign_schema' ] , |
|
122 | - 'table' => $constrant[ 'foreign_table' ] , |
|
123 | - 'column' => $constrant[ 'foreign_column' ] , |
|
117 | + $objConstrant = Constrant::getInstance() |
|
118 | + ->populate( |
|
119 | + array( |
|
120 | + 'constrant' => $constrant['constraint_name'], |
|
121 | + 'schema' => $constrant['foreign_schema'], |
|
122 | + 'table' => $constrant['foreign_table'], |
|
123 | + 'column' => $constrant['foreign_column'], |
|
124 | 124 | 'database' => $this->database |
125 | 125 | ) |
126 | 126 | ); |
127 | 127 | |
128 | - switch ( $constrant[ 'constraint_type' ] ) |
|
128 | + switch ($constrant['constraint_type']) |
|
129 | 129 | { |
130 | 130 | case "FOREIGN KEY": |
131 | - $table->getColumn ( $constrant[ "column_name" ] ) |
|
132 | - ->addRefFk ( $objConstrant ); |
|
131 | + $table->getColumn($constrant["column_name"]) |
|
132 | + ->addRefFk($objConstrant); |
|
133 | 133 | break; |
134 | 134 | case"PRIMARY KEY": |
135 | - $table->getColumn ( $constrant[ "column_name" ] ) |
|
136 | - ->setPrimaryKey ( $objConstrant ) |
|
137 | - ->setSequence ( |
|
138 | - $this->getSequence ( |
|
139 | - $table_name , |
|
140 | - $constrant[ "column_name" ] , |
|
135 | + $table->getColumn($constrant["column_name"]) |
|
136 | + ->setPrimaryKey($objConstrant) |
|
137 | + ->setSequence( |
|
138 | + $this->getSequence( |
|
139 | + $table_name, |
|
140 | + $constrant["column_name"], |
|
141 | 141 | $schema |
142 | 142 | ) |
143 | 143 | ); |
@@ -152,20 +152,20 @@ discard block |
||
152 | 152 | * @param string $table_name |
153 | 153 | * @param int $schema |
154 | 154 | */ |
155 | - private function populateDependece ( $constrant , $table_name , $schema = 0 ) |
|
155 | + private function populateDependece($constrant, $table_name, $schema = 0) |
|
156 | 156 | { |
157 | - if ( $this->hasTable ( $table_name , $schema ) ) |
|
157 | + if ($this->hasTable($table_name, $schema)) |
|
158 | 158 | { |
159 | - $table = $this->getTable ( $table_name , $schema ); |
|
160 | - if ( $table->hasColumn ( $constrant[ "foreign_column" ] ) ) |
|
159 | + $table = $this->getTable($table_name, $schema); |
|
160 | + if ($table->hasColumn($constrant["foreign_column"])) |
|
161 | 161 | { |
162 | - $table->getColumn ( $constrant[ "foreign_column" ] ) |
|
163 | - ->createDependece ( |
|
164 | - $constrant[ 'constraint_name' ] , |
|
165 | - $constrant[ 'table_name' ] , |
|
166 | - $constrant[ 'column_name' ] , |
|
167 | - $this->database , |
|
168 | - $constrant[ 'table_schema' ] |
|
162 | + $table->getColumn($constrant["foreign_column"]) |
|
163 | + ->createDependece( |
|
164 | + $constrant['constraint_name'], |
|
165 | + $constrant['table_name'], |
|
166 | + $constrant['column_name'], |
|
167 | + $this->database, |
|
168 | + $constrant['table_schema'] |
|
169 | 169 | ); |
170 | 170 | } |
171 | 171 | } |
@@ -174,37 +174,37 @@ discard block |
||
174 | 174 | /** |
175 | 175 | * cria um Array com nome das tabelas |
176 | 176 | */ |
177 | - public function parseTables () |
|
177 | + public function parseTables() |
|
178 | 178 | { |
179 | - if ( $this->hasTables () ) |
|
179 | + if ($this->hasTables()) |
|
180 | 180 | { |
181 | - return $this->getAllTables (); |
|
181 | + return $this->getAllTables(); |
|
182 | 182 | } |
183 | 183 | |
184 | - foreach ( $this->getListColumns () as $table ) |
|
184 | + foreach ($this->getListColumns() as $table) |
|
185 | 185 | { |
186 | - $schema = $table[ 'table_schema' ]; |
|
187 | - $key = $table [ 'table_name' ]; |
|
188 | - if ( ! $this->hasTable ( $key , $schema ) ) |
|
186 | + $schema = $table['table_schema']; |
|
187 | + $key = $table ['table_name']; |
|
188 | + if ( ! $this->hasTable($key, $schema)) |
|
189 | 189 | { |
190 | - $this->createTable ( $key , $schema ); |
|
190 | + $this->createTable($key, $schema); |
|
191 | 191 | } |
192 | 192 | |
193 | - $column = Column::getInstance () |
|
194 | - ->populate ( |
|
195 | - array ( |
|
196 | - 'name' => $table [ 'column_name' ] , |
|
197 | - 'type' => $this->convertTypeToSimple ( $table[ 'data_type' ] ) , |
|
198 | - 'nullable' => (is_string($table[ 'is_nullable' ]) && strtolower($table[ 'is_nullable' ]) != 'no' ) , |
|
199 | - 'max_length' => $table[ 'max_length' ], |
|
193 | + $column = Column::getInstance() |
|
194 | + ->populate( |
|
195 | + array( |
|
196 | + 'name' => $table ['column_name'], |
|
197 | + 'type' => $this->convertTypeToSimple($table['data_type']), |
|
198 | + 'nullable' => (is_string($table['is_nullable']) && strtolower($table['is_nullable']) != 'no'), |
|
199 | + 'max_length' => $table['max_length'], |
|
200 | 200 | 'column_default' => $table ['column_default'] |
201 | 201 | ) |
202 | 202 | ); |
203 | 203 | |
204 | - $this->getTable ( $key , $schema ) |
|
205 | - ->addColumn ( $column ) |
|
206 | - ->setNamespace ( |
|
207 | - $this->config->createClassNamespace ( $this->getTable ( $key , $schema ) ) |
|
204 | + $this->getTable($key, $schema) |
|
205 | + ->addColumn($column) |
|
206 | + ->setNamespace( |
|
207 | + $this->config->createClassNamespace($this->getTable($key, $schema)) |
|
208 | 208 | ); |
209 | 209 | } |
210 | 210 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * |
215 | 215 | * @return int |
216 | 216 | */ |
217 | - abstract public function getTotalTables (); |
|
217 | + abstract public function getTotalTables(); |
|
218 | 218 | |
219 | 219 | /** |
220 | 220 | * Retorna o Nome da Sequence da tabela |
@@ -224,33 +224,33 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @return string |
226 | 226 | */ |
227 | - abstract public function getSequence ( $table , $column , $schema = 0 ); |
|
227 | + abstract public function getSequence($table, $column, $schema = 0); |
|
228 | 228 | |
229 | 229 | /** |
230 | 230 | * @return array |
231 | 231 | */ |
232 | - abstract public function getListConstrant (); |
|
232 | + abstract public function getListConstrant(); |
|
233 | 233 | |
234 | 234 | /** |
235 | 235 | * @param string $str |
236 | 236 | * |
237 | 237 | * @return string |
238 | 238 | */ |
239 | - protected function convertTypeToPhp ( $str ) |
|
239 | + protected function convertTypeToPhp($str) |
|
240 | 240 | { |
241 | - if ( isset( $this->dataTypesToPhp[ $str ] ) ) |
|
241 | + if (isset($this->dataTypesToPhp[$str])) |
|
242 | 242 | { |
243 | - return $this->dataTypesToPhp[ $str ]; |
|
243 | + return $this->dataTypesToPhp[$str]; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | return 'string'; |
247 | 247 | } |
248 | 248 | |
249 | - protected function convertTypeToSimple ( $str ) |
|
249 | + protected function convertTypeToSimple($str) |
|
250 | 250 | { |
251 | - if ( isset( $this->dataTypesToSimple[ $str ] ) ) |
|
251 | + if (isset($this->dataTypesToSimple[$str])) |
|
252 | 252 | { |
253 | - return $this->dataTypesToSimple[ $str ]; |
|
253 | + return $this->dataTypesToSimple[$str]; |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | return 'string'; |
@@ -259,12 +259,12 @@ discard block |
||
259 | 259 | /** |
260 | 260 | * @return string |
261 | 261 | */ |
262 | - abstract public function getPDOString (); |
|
262 | + abstract public function getPDOString(); |
|
263 | 263 | |
264 | 264 | /** |
265 | 265 | * @return string |
266 | 266 | */ |
267 | - abstract public function getPDOSocketString (); |
|
267 | + abstract public function getPDOSocketString(); |
|
268 | 268 | |
269 | 269 | /** |
270 | 270 | * @param $nameTable |
@@ -272,18 +272,18 @@ discard block |
||
272 | 272 | * |
273 | 273 | * @return \Classes\Db\DbTable |
274 | 274 | */ |
275 | - public function createTable ( $nameTable , $schema = 0 ) |
|
275 | + public function createTable($nameTable, $schema = 0) |
|
276 | 276 | { |
277 | - if ( ! isset( $this->objDbTables[ strtoupper($schema) ] ) ) |
|
277 | + if ( ! isset($this->objDbTables[strtoupper($schema)])) |
|
278 | 278 | { |
279 | - $this->objDbTables[ strtoupper($schema) ] = new DbTables(); |
|
279 | + $this->objDbTables[strtoupper($schema)] = new DbTables(); |
|
280 | 280 | } |
281 | 281 | |
282 | - $this->objDbTables[ strtoupper($schema) ][ trim ( $nameTable ) ] = DbTable::getInstance () |
|
283 | - ->populate ( |
|
284 | - array ( |
|
285 | - 'table' => $nameTable , |
|
286 | - 'schema' => $schema , |
|
282 | + $this->objDbTables[strtoupper($schema)][trim($nameTable)] = DbTable::getInstance() |
|
283 | + ->populate( |
|
284 | + array( |
|
285 | + 'table' => $nameTable, |
|
286 | + 'schema' => $schema, |
|
287 | 287 | 'database' => $this->database |
288 | 288 | ) |
289 | 289 | ); |
@@ -296,24 +296,24 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @return \Classes\Db\Iterators\DbTables |
298 | 298 | */ |
299 | - public function getTables ( $schema = 0 ) |
|
299 | + public function getTables($schema = 0) |
|
300 | 300 | { |
301 | - if ( ! isset( $this->objDbTables[ strtoupper($schema) ] ) ) |
|
301 | + if ( ! isset($this->objDbTables[strtoupper($schema)])) |
|
302 | 302 | { |
303 | - return array (); |
|
303 | + return array(); |
|
304 | 304 | } |
305 | 305 | |
306 | - return $this->objDbTables[ strtoupper($schema) ]; |
|
306 | + return $this->objDbTables[strtoupper($schema)]; |
|
307 | 307 | } |
308 | 308 | |
309 | - public function getAllTables () |
|
309 | + public function getAllTables() |
|
310 | 310 | { |
311 | 311 | return $this->objDbTables; |
312 | 312 | } |
313 | 313 | |
314 | - public function hasTables () |
|
314 | + public function hasTables() |
|
315 | 315 | { |
316 | - return ! empty( $this->objDbTables ); |
|
316 | + return ! empty($this->objDbTables); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -323,9 +323,9 @@ discard block |
||
323 | 323 | * |
324 | 324 | * @return \Classes\Db\DbTable |
325 | 325 | */ |
326 | - public function getTable ( $nameTable , $schema = 0 ) |
|
326 | + public function getTable($nameTable, $schema = 0) |
|
327 | 327 | { |
328 | - return $this->objDbTables[ strtoupper($schema) ][ trim ( $nameTable ) ]; |
|
328 | + return $this->objDbTables[strtoupper($schema)][trim($nameTable)]; |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | /** |
@@ -334,9 +334,9 @@ discard block |
||
334 | 334 | * |
335 | 335 | * @return bool |
336 | 336 | */ |
337 | - public function hasTable ( $nameTable , $schema = 0 ) |
|
337 | + public function hasTable($nameTable, $schema = 0) |
|
338 | 338 | { |
339 | - return isset( $this->objDbTables[ strtoupper($schema) ][ trim ( $nameTable ) ] ); |
|
339 | + return isset($this->objDbTables[strtoupper($schema)][trim($nameTable)]); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | /** |
@@ -344,66 +344,66 @@ discard block |
||
344 | 344 | * |
345 | 345 | * @return array[] |
346 | 346 | */ |
347 | - abstract public function getListColumns (); |
|
347 | + abstract public function getListColumns(); |
|
348 | 348 | |
349 | 349 | /** |
350 | 350 | * Retorna um Array com nome das tabelas |
351 | 351 | * |
352 | 352 | * @return string[] |
353 | 353 | */ |
354 | - abstract public function getListNameTable (); |
|
354 | + abstract public function getListNameTable(); |
|
355 | 355 | |
356 | 356 | /** |
357 | 357 | * @param \Classes\AdapterConfig\AbstractAdapter $adapterConfig |
358 | 358 | */ |
359 | - public function __construct ( AbstractAdapter $adapterConfig ) |
|
359 | + public function __construct(AbstractAdapter $adapterConfig) |
|
360 | 360 | { |
361 | 361 | $this->config = $adapterConfig; |
362 | - $this->host = $adapterConfig->getHost (); |
|
363 | - $this->database = $adapterConfig->getDatabase (); |
|
364 | - $this->port = $adapterConfig->hasPort () ? $adapterConfig->getPort () |
|
362 | + $this->host = $adapterConfig->getHost(); |
|
363 | + $this->database = $adapterConfig->getDatabase(); |
|
364 | + $this->port = $adapterConfig->hasPort() ? $adapterConfig->getPort() |
|
365 | 365 | : $this->port; |
366 | - $this->username = $adapterConfig->getUser (); |
|
367 | - $this->password = $adapterConfig->getPassword (); |
|
368 | - $this->socket = $adapterConfig->getSocket (); |
|
369 | - $this->tablesName = $adapterConfig->hasTablesName () |
|
370 | - ? $adapterConfig->getListTablesName () : ''; |
|
366 | + $this->username = $adapterConfig->getUser(); |
|
367 | + $this->password = $adapterConfig->getPassword(); |
|
368 | + $this->socket = $adapterConfig->getSocket(); |
|
369 | + $this->tablesName = $adapterConfig->hasTablesName() |
|
370 | + ? $adapterConfig->getListTablesName() : ''; |
|
371 | 371 | |
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
375 | 375 | * Executa as consultas do banco de dados |
376 | 376 | */ |
377 | - public function runDatabase () |
|
377 | + public function runDatabase() |
|
378 | 378 | { |
379 | - $this->parseTables (); |
|
380 | - $this->parseConstrants (); |
|
379 | + $this->parseTables(); |
|
380 | + $this->parseConstrants(); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
384 | 384 | * |
385 | 385 | * @return \PDO |
386 | 386 | */ |
387 | - public function getPDO () |
|
387 | + public function getPDO() |
|
388 | 388 | { |
389 | - if ( is_null ( $this->_pdo ) ) |
|
389 | + if (is_null($this->_pdo)) |
|
390 | 390 | { |
391 | - if ( ! empty( $this->socket ) ) |
|
391 | + if ( ! empty($this->socket)) |
|
392 | 392 | { |
393 | - $pdoString = $this->getPDOSocketString (); |
|
393 | + $pdoString = $this->getPDOSocketString(); |
|
394 | 394 | } else |
395 | 395 | { |
396 | - $pdoString = $this->getPDOString (); |
|
396 | + $pdoString = $this->getPDOString(); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | try |
400 | 400 | { |
401 | - $this->_pdo = new \PDO ( |
|
402 | - $pdoString , $this->username , $this->password |
|
401 | + $this->_pdo = new \PDO( |
|
402 | + $pdoString, $this->username, $this->password |
|
403 | 403 | ); |
404 | - } catch ( \Exception $e ) |
|
404 | + } catch (\Exception $e) |
|
405 | 405 | { |
406 | - die ( "\033[0;31mPDO error: " . $e->getMessage () . "\033[0m\n" ); |
|
406 | + die ("\033[0;31mPDO error: " . $e->getMessage() . "\033[0m\n"); |
|
407 | 407 | } |
408 | 408 | } |
409 | 409 |