@@ -3,19 +3,19 @@ discard block |
||
3 | 3 | /** |
4 | 4 | * Application Entity |
5 | 5 | * |
6 | - * <?=$this->config->last_modify."\n"?> |
|
6 | + * <?=$this->config->last_modify . "\n"?> |
|
7 | 7 | * |
8 | 8 | * @package <?=$this->config->namespace?>Model |
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 | -abstract class <?=$this->config->namespace?$this->config->namespace."_":""?>Model_EntityAbstract extends Zend_Db_Table_Row_Abstract |
|
18 | +abstract class <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>Model_EntityAbstract extends Zend_Db_Table_Row_Abstract |
|
19 | 19 | { |
20 | 20 | |
21 | 21 | /** |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | /** |
77 | 77 | * @param array $data |
78 | - * @return <?=$this->config->namespace?$this->config->namespace."_":""?>Model_EntityAbstract |
|
78 | + * @return <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>Model_EntityAbstract |
|
79 | 79 | */ |
80 | 80 | public static function getIntance($data = array()) |
81 | 81 | { |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | /** |
243 | 243 | * Retorna o nome da coluna da primary key |
244 | 244 | * |
245 | - * @see <?=$this->config->namespace?$this->config->namespace."_":""?>Model_DbTable_TableAbstract::getPrimaryKeyName() |
|
245 | + * @see <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>Model_DbTable_TableAbstract::getPrimaryKeyName() |
|
246 | 246 | * @return string|array The name or array of names which form the primary key |
247 | 247 | */ |
248 | 248 | public function getPrimaryKeyName() |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | /** |
254 | 254 | * @param int $primarykey |
255 | 255 | * |
256 | - * @return <?=$this->config->namespace?$this->config->namespace."_":""?>Model_EntityAbstract |
|
256 | + * @return <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>Model_EntityAbstract |
|
257 | 257 | */ |
258 | 258 | public function find ( $primarykey ) |
259 | 259 | { |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | /** |
268 | 268 | * @see Zend_Db_Table_Rowset_Abstract::fetchAll |
269 | 269 | * |
270 | - * @return <?=$this->config->namespace?$this->config->namespace."_":""?>Model_EntityAbstract[] |
|
270 | + * @return <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>Model_EntityAbstract[] |
|
271 | 271 | */ |
272 | 272 | public function fetchAll ( $where = null , $order = null , $count = null , $offset = null ) |
273 | 273 | { |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * Retorna o objeto pela primary key |
279 | 279 | * |
280 | 280 | * @param int|array $primary_key |
281 | - * @return <?=$this->config->namespace?$this->config->namespace."_":""?>Model_EntityAbstract |
|
281 | + * @return <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>Model_EntityAbstract |
|
282 | 282 | */ |
283 | 283 | public static function retrieve ( $primarykey ) |
284 | 284 | { |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?= "<?php\n" ?> |
2 | -<?php $classNameModel = $objTables->getNamespace () . '_' . \Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () ) ?> |
|
3 | -<?php $className = $objTables->getNamespace () . '_Entity_' . \Classes\Maker\AbstractMaker::getClassName ( |
|
4 | - $objTables->getName () |
|
2 | +<?php $classNameModel = $objTables->getNamespace() . '_' . \Classes\Maker\AbstractMaker::getClassName($objTables->getName()) ?> |
|
3 | +<?php $className = $objTables->getNamespace() . '_Entity_' . \Classes\Maker\AbstractMaker::getClassName( |
|
4 | + $objTables->getName() |
|
5 | 5 | ) ?> |
6 | 6 | |
7 | 7 | /** |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * |
10 | 10 | * <?= $this->config->last_modify . "\n" ?> |
11 | 11 | * |
12 | - * @package <?= $objTables->getNamespace () . "\n" ?> |
|
12 | + * @package <?= $objTables->getNamespace() . "\n" ?> |
|
13 | 13 | * @subpackage Entity |
14 | 14 | * |
15 | 15 | * @author <?= $this->config->author . "\n" ?> |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | . "_" : "" ?>Model_<?= $objMakeFile->getFilesFixeds('parentClass')->getFileName() . "\n" ?> |
29 | 29 | { |
30 | 30 | |
31 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
31 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
32 | 32 | /** |
33 | - * Database constraint in the column <?= $column->getName () . "\n" ?> |
|
33 | + * Database constraint in the column <?= $column->getName() . "\n" ?> |
|
34 | 34 | * |
35 | 35 | */ |
36 | - const <?= strtoupper ( $column->getName () ) ?> = '<?= $objTables->getName () ?>.<?= $column->getName () ?>'; |
|
36 | + const <?= strtoupper($column->getName()) ?> = '<?= $objTables->getName() ?>.<?= $column->getName() ?>'; |
|
37 | 37 | <?php endforeach; ?> |
38 | 38 | |
39 | 39 | /** |
@@ -42,17 +42,17 @@ discard block |
||
42 | 42 | * @var string |
43 | 43 | * @access protected |
44 | 44 | */ |
45 | - protected $_tableClass = '<?= $objTables->getNamespace () ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName ( |
|
46 | - $objTables->getName () |
|
45 | + protected $_tableClass = '<?= $objTables->getNamespace() ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName( |
|
46 | + $objTables->getName() |
|
47 | 47 | ) ?>'; |
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @see <?= $this->config->namespace ?>Model_EntityAbstract::$_columnsList |
51 | 51 | */ |
52 | 52 | protected $_columnsList = array( |
53 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
54 | - self::<?= strtoupper ( $column->getName () ) ?> => '<?= strtolower ( |
|
55 | - \Classes\Maker\AbstractMaker::getClassName ( $column->getName () ) |
|
53 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
54 | + self::<?= strtoupper($column->getName()) ?> => '<?= strtolower( |
|
55 | + \Classes\Maker\AbstractMaker::getClassName($column->getName()) |
|
56 | 56 | ) ?>', |
57 | 57 | <?php endforeach; ?> |
58 | 58 | ); |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | * @see <?= $this->config->namespace ?>Model_EntityAbstract::$_filters |
62 | 62 | */ |
63 | 63 | protected $_filters = array( |
64 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
64 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
65 | 65 | <?php |
66 | 66 | $filters = null; |
67 | - switch ( strtolower ( $column->getType () ) ) { |
|
67 | + switch (strtolower($column->getType())) { |
|
68 | 68 | case 'string': |
69 | 69 | $filters = 'StripTags", "StringTrim'; |
70 | 70 | break; |
@@ -78,15 +78,15 @@ discard block |
||
78 | 78 | case 'datetime': |
79 | 79 | break; |
80 | 80 | case 'boolean': |
81 | - $filters='Int'; |
|
81 | + $filters = 'Int'; |
|
82 | 82 | break; |
83 | 83 | default: |
84 | - $filters = ucfirst ( $column->getType () ); |
|
84 | + $filters = ucfirst($column->getType()); |
|
85 | 85 | break; |
86 | 86 | } |
87 | 87 | ?> |
88 | - '<?= $column->getName () ?>' => array ( |
|
89 | - <?= ( !empty( $filters ) ) ? "\"{$filters}\"\n" : null; ?> |
|
88 | + '<?= $column->getName() ?>' => array ( |
|
89 | + <?= ( ! empty($filters)) ? "\"{$filters}\"\n" : null; ?> |
|
90 | 90 | ), |
91 | 91 | <?php endforeach; ?> |
92 | 92 | ); |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | * @see <?= $this->config->namespace ?>Model_EntityAbstract::$_validators |
96 | 96 | */ |
97 | 97 | protected $_validators= array( |
98 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
98 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
99 | 99 | <?php |
100 | - $validators = array (); |
|
100 | + $validators = array(); |
|
101 | 101 | |
102 | - $validators[] = $column->isNullable () ? "'allowEmpty' => true" : "'NotEmpty'"; |
|
102 | + $validators[] = $column->isNullable() ? "'allowEmpty' => true" : "'NotEmpty'"; |
|
103 | 103 | |
104 | - switch ( strtolower ( $column->getType () ) ) { |
|
104 | + switch (strtolower($column->getType())) { |
|
105 | 105 | case 'date': |
106 | 106 | break; |
107 | 107 | case 'timestamp': |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | case 'datetime': |
110 | 110 | break; |
111 | 111 | case 'string': |
112 | - if ( $column->getMaxLength () ) { |
|
113 | - $validators[] = "array( 'StringLength', array( 'max' => " . $column->getMaxLength () . " ) )"; |
|
112 | + if ($column->getMaxLength()) { |
|
113 | + $validators[] = "array( 'StringLength', array( 'max' => " . $column->getMaxLength() . " ) )"; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | break; |
@@ -118,18 +118,18 @@ discard block |
||
118 | 118 | $validators[] = "'Int'"; |
119 | 119 | break; |
120 | 120 | default: |
121 | - $name = ucfirst ( $column->getType () ); |
|
121 | + $name = ucfirst($column->getType()); |
|
122 | 122 | $validators[] = "'$name'"; |
123 | 123 | break; |
124 | 124 | } |
125 | -$validators = implode ( ", ", $validators ) ?> |
|
126 | - '<?= $column->getName () ?>' => array ( |
|
127 | - <?= ( !empty( $validators ) ) ? "{$validators}\n" : null ?> |
|
125 | +$validators = implode(", ", $validators) ?> |
|
126 | + '<?= $column->getName() ?>' => array ( |
|
127 | + <?= ( ! empty($validators)) ? "{$validators}\n" : null ?> |
|
128 | 128 | ), |
129 | 129 | <?php endforeach; ?> |
130 | 130 | ); |
131 | 131 | |
132 | -<?php if ( $objTables->hasPrimaryKey () ): ?> |
|
132 | +<?php if ($objTables->hasPrimaryKey()): ?> |
|
133 | 133 | /** |
134 | 134 | * Nome da Primary Key |
135 | 135 | * |
@@ -137,171 +137,171 @@ discard block |
||
137 | 137 | * @access protected |
138 | 138 | */ |
139 | 139 | protected $_primary = array( |
140 | -<?php foreach ( $objTables->getPrimarykeys () as $pks ) : ?> |
|
141 | - '<?= $pks->getName () ?>', |
|
140 | +<?php foreach ($objTables->getPrimarykeys() as $pks) : ?> |
|
141 | + '<?= $pks->getName() ?>', |
|
142 | 142 | <?php endforeach ?> |
143 | 143 | ); |
144 | 144 | <?php endif ?> |
145 | 145 | |
146 | -<?php foreach ( $parents as $parent ): ?> |
|
146 | +<?php foreach ($parents as $parent): ?> |
|
147 | 147 | /** |
148 | - * Parent relation <?= \Classes\Maker\AbstractMaker::getClassName ( $parent[ 'table' ] ) . "\n" ?> |
|
148 | + * Parent relation <?= \Classes\Maker\AbstractMaker::getClassName($parent['table']) . "\n" ?> |
|
149 | 149 | * |
150 | - * - CONSTRAINT in DB <?= $parent[ 'name' ] . "\n" ?> |
|
150 | + * - CONSTRAINT in DB <?= $parent['name'] . "\n" ?> |
|
151 | 151 | * |
152 | - * @var <?= $parent[ 'variable' ] . "\n" ?> |
|
152 | + * @var <?= $parent['variable'] . "\n" ?> |
|
153 | 153 | */ |
154 | - protected $_parent_<?= $parent[ 'variable' ] ?>; |
|
154 | + protected $_parent_<?= $parent['variable'] ?>; |
|
155 | 155 | |
156 | 156 | <?php endforeach; ?> |
157 | -<?php foreach ( $depends as $depend ): ?> |
|
157 | +<?php foreach ($depends as $depend): ?> |
|
158 | 158 | /** |
159 | - * Depends relation <?= \Classes\Maker\AbstractMaker::getClassName ( $depend[ 'table' ] ) . "\n" ?> |
|
159 | + * Depends relation <?= \Classes\Maker\AbstractMaker::getClassName($depend['table']) . "\n" ?> |
|
160 | 160 | * |
161 | - * - CONSTRAINT in DB <?= $depend[ 'name' ] . "\n" ?> |
|
161 | + * - CONSTRAINT in DB <?= $depend['name'] . "\n" ?> |
|
162 | 162 | * |
163 | - * @var <?= $depend[ 'variable' ] . "\n" ?> |
|
163 | + * @var <?= $depend['variable'] . "\n" ?> |
|
164 | 164 | */ |
165 | - protected $_depend_<?= $depend[ 'variable' ] ?>; |
|
165 | + protected $_depend_<?= $depend['variable'] ?>; |
|
166 | 166 | |
167 | 167 | <?php endforeach; ?> |
168 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
168 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
169 | 169 | /** |
170 | 170 | * |
171 | - * Sets column <?= $column->getName () . "\n" ?> |
|
171 | + * Sets column <?= $column->getName() . "\n" ?> |
|
172 | 172 | * |
173 | -<?php if ( $column->equalType ( 'date' ) ): ?> |
|
173 | +<?php if ($column->equalType('date')): ?> |
|
174 | 174 | * Stored in ISO 8601 format. |
175 | 175 | * |
176 | - * @param string|Zend_Date $<?= $column->getName () . "\n" ?> |
|
176 | + * @param string|Zend_Date $<?= $column->getName() . "\n" ?> |
|
177 | 177 | <?php else: ?> |
178 | - * @param <?= $column->getType () ?> $<?= $column->getName () . "\n" ?> |
|
178 | + * @param <?= $column->getType() ?> $<?= $column->getName() . "\n" ?> |
|
179 | 179 | <?php endif; ?> |
180 | 180 | * @return <?= $className . "\n" ?> |
181 | 181 | */ |
182 | - public function set<?= \Classes\Maker\AbstractMaker::getClassName ( $column->getName () ) ?>( $<?= $column->getName ( |
|
182 | + public function set<?= \Classes\Maker\AbstractMaker::getClassName($column->getName()) ?>( $<?= $column->getName( |
|
183 | 183 | ) ?> ) |
184 | 184 | { |
185 | -<?php switch ( strtolower( $column->getType () ) ): |
|
185 | +<?php switch (strtolower($column->getType())): |
|
186 | 186 | case 'timestamp': |
187 | 187 | case 'date': |
188 | 188 | case 'datetime':?> |
189 | - if (! empty($<?= $column->getName () ?>)) |
|
189 | + if (! empty($<?= $column->getName() ?>)) |
|
190 | 190 | { |
191 | - if (! $<?= $column->getName () ?> instanceof Zend_Date) |
|
191 | + if (! $<?= $column->getName() ?> instanceof Zend_Date) |
|
192 | 192 | { |
193 | - $<?= $column->getName () ?> = new Zend_Date($<?= $column->getName () ?>); |
|
193 | + $<?= $column->getName() ?> = new Zend_Date($<?= $column->getName() ?>); |
|
194 | 194 | } |
195 | -<?php if( $column->equalType ( 'date' ) ): ?> |
|
196 | - $<?= $column->getName () ?>->setOptions(array('format_type' => 'php')); |
|
195 | +<?php if ($column->equalType('date')): ?> |
|
196 | + $<?= $column->getName() ?>->setOptions(array('format_type' => 'php')); |
|
197 | 197 | <?php endif ?> |
198 | -<?php $format = 'Zend_Date::ISO_8601' ?> |
|
199 | -<?php if( $column->equalType ( 'date' ) ) { $format = '\'Y-m-d\''; } ?> |
|
200 | - $<?= $column->getName () ?> = $<?= $column->getName () ?>->toString( <?=$format?> ); |
|
198 | +<?php $format = 'Zend_Date::ISO_8601' ?> |
|
199 | +<?php if ($column->equalType('date')) { $format = '\'Y-m-d\''; } ?> |
|
200 | + $<?= $column->getName() ?> = $<?= $column->getName() ?>->toString( <?=$format?> ); |
|
201 | 201 | } |
202 | -<?php if($column->isNullable ()):?> |
|
202 | +<?php if ($column->isNullable()):?> |
|
203 | 203 | else{ |
204 | - $<?= $column->getName () ?> = null; |
|
204 | + $<?= $column->getName() ?> = null; |
|
205 | 205 | } |
206 | 206 | <?php endif ?> |
207 | 207 | <?php break; |
208 | 208 | case 'boolean': |
209 | -if(!$column->isNullable ()):?> |
|
210 | - $<?= $column->getName () ?> = ( int ) $<?= $column->getName () ?> ; |
|
209 | +if ( ! $column->isNullable()):?> |
|
210 | + $<?= $column->getName() ?> = ( int ) $<?= $column->getName() ?> ; |
|
211 | 211 | <?php endif ?> |
212 | 212 | <?php default: ?> |
213 | -<?php if(!$column->isNullable () && ($column->getType () != 'boolean')):?> |
|
214 | - $<?= $column->getName () ?> = (<?= ucfirst ( $column->getType () ) ?>) $<?= $column->getName () ?> ; |
|
213 | +<?php if ( ! $column->isNullable() && ($column->getType() != 'boolean')):?> |
|
214 | + $<?= $column->getName() ?> = (<?= ucfirst($column->getType()) ?>) $<?= $column->getName() ?> ; |
|
215 | 215 | <?php endif ?> |
216 | - $input = new Zend_Filter_Input($this->_filters, $this->_validators, array('<?= $column->getName () ?>'=>$<?= $column->getName () ?> )); |
|
216 | + $input = new Zend_Filter_Input($this->_filters, $this->_validators, array('<?= $column->getName() ?>'=>$<?= $column->getName() ?> )); |
|
217 | 217 | |
218 | - if(!$input->isValid ('<?= $column->getName () ?>')) |
|
218 | + if(!$input->isValid ('<?= $column->getName() ?>')) |
|
219 | 219 | { |
220 | 220 | $errors = $input->getMessages (); |
221 | - foreach ( $errors['<?= $column->getName () ?>'] as $key => $value ) |
|
221 | + foreach ( $errors['<?= $column->getName() ?>'] as $key => $value ) |
|
222 | 222 | { |
223 | - throw new <?= $this->config->namespace ? $this->config->namespace . "_" : "" ?>Model_EntityException ( '<?= $column->getName () ?> - ' . $value ); |
|
223 | + throw new <?= $this->config->namespace ? $this->config->namespace . "_" : "" ?>Model_EntityException ( '<?= $column->getName() ?> - ' . $value ); |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | <?php break ?> |
227 | 227 | <?php endswitch ?> |
228 | 228 | |
229 | - $this-><?= $column->getName () ?> = $<?= $column->getName () ?> ; |
|
229 | + $this-><?= $column->getName() ?> = $<?= $column->getName() ?> ; |
|
230 | 230 | return $this; |
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
234 | - * Gets column <?= $column->getName () . "\n" ?> |
|
234 | + * Gets column <?= $column->getName() . "\n" ?> |
|
235 | 235 | * |
236 | -<?php if ( $column->equalType ( 'date' ) or $column->equalType ( 'datetime' ) or $column->equalType ( 'timestamp' ) ): ?> |
|
236 | +<?php if ($column->equalType('date') or $column->equalType('datetime') or $column->equalType('timestamp')): ?> |
|
237 | 237 | * @param boolean $returnZendDate |
238 | 238 | * @return Zend_Date|null|string Zend_Date representation of this datetime if enabled, or ISO 8601 string if not |
239 | 239 | <?php else: ?> |
240 | - * @return <?= $column->getType () . "\n" ?> |
|
240 | + * @return <?= $column->getType() . "\n" ?> |
|
241 | 241 | <?php endif; ?> |
242 | 242 | */ |
243 | - public function get<?= \Classes\Maker\AbstractMaker::getClassName ( |
|
244 | - $column->getName () |
|
245 | - ) ?>(<?php if ( $column->equalType ( 'date' ) or $column->equalType ( 'datetime' ) or $column->equalType ( 'timestamp' ) ): ?>$format = false <?php endif; ?>) |
|
243 | + public function get<?= \Classes\Maker\AbstractMaker::getClassName( |
|
244 | + $column->getName() |
|
245 | + ) ?>(<?php if ($column->equalType('date') or $column->equalType('datetime') or $column->equalType('timestamp')): ?>$format = false <?php endif; ?>) |
|
246 | 246 | { |
247 | -<?php switch ( strtolower( $column->getType () ) ): |
|
247 | +<?php switch (strtolower($column->getType())): |
|
248 | 248 | case 'timestamp': |
249 | 249 | case 'date': |
250 | 250 | case 'datetime':?> |
251 | 251 | if ($format) |
252 | 252 | { |
253 | - if ($this->_data['<?= $column->getName () ?>'] === null) |
|
253 | + if ($this->_data['<?= $column->getName() ?>'] === null) |
|
254 | 254 | { |
255 | 255 | return null; |
256 | 256 | } |
257 | 257 | |
258 | - $objDate = new Zend_Date($this-><?= $column->getName () ?>, $format ); |
|
258 | + $objDate = new Zend_Date($this-><?= $column->getName() ?>, $format ); |
|
259 | 259 | |
260 | 260 | return $objDate->toString($format); |
261 | 261 | } |
262 | 262 | <?php break ?> |
263 | 263 | <?php endswitch ?> |
264 | - return $this-><?= $column->getName () ?>; |
|
264 | + return $this-><?= $column->getName() ?>; |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | <?php endforeach; ?> |
268 | -<?php foreach ( $parents as $parent ): ?> |
|
268 | +<?php foreach ($parents as $parent): ?> |
|
269 | 269 | /** |
270 | - * Gets parent <?= $parent[ 'table' ] . "\n" ?> |
|
270 | + * Gets parent <?= $parent['table'] . "\n" ?> |
|
271 | 271 | * |
272 | - * @return <?= $parent[ 'class' ] . "\n" ?> |
|
272 | + * @return <?= $parent['class'] . "\n" ?> |
|
273 | 273 | */ |
274 | - public function get<?= $parent[ 'function' ] ?>() |
|
274 | + public function get<?= $parent['function'] ?>() |
|
275 | 275 | { |
276 | - if ($this->_parent_<?= $parent[ 'variable' ] ?> === null) |
|
276 | + if ($this->_parent_<?= $parent['variable'] ?> === null) |
|
277 | 277 | { |
278 | - $this->_parent_<?= $parent[ 'variable' ] ?> = $this->findParentRow('<?= $objTables->getNamespace ( |
|
279 | - ) ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName ( |
|
280 | - $parent[ 'table' ] |
|
281 | - ) ?>', '<?= \Classes\Maker\AbstractMaker::getClassName ( $parent[ 'variable' ] ) ?>'); |
|
278 | + $this->_parent_<?= $parent['variable'] ?> = $this->findParentRow('<?= $objTables->getNamespace( |
|
279 | + ) ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName( |
|
280 | + $parent['table'] |
|
281 | + ) ?>', '<?= \Classes\Maker\AbstractMaker::getClassName($parent['variable']) ?>'); |
|
282 | 282 | } |
283 | 283 | |
284 | - return $this->_parent_<?= $parent[ 'variable' ] ?>; |
|
284 | + return $this->_parent_<?= $parent['variable'] ?>; |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | <?php endforeach; ?> |
288 | 288 | |
289 | 289 | |
290 | -<?php foreach ( $depends as $depend ): ?> |
|
290 | +<?php foreach ($depends as $depend): ?> |
|
291 | 291 | /** |
292 | - * Gets dependent <?= $depend[ 'table' ] . "\n" ?> |
|
292 | + * Gets dependent <?= $depend['table'] . "\n" ?> |
|
293 | 293 | * |
294 | - * @return <?= $depend[ 'class' ] . "\n" ?> |
|
294 | + * @return <?= $depend['class'] . "\n" ?> |
|
295 | 295 | */ |
296 | - public function get<?= $depend[ 'function' ] ?>() |
|
296 | + public function get<?= $depend['function'] ?>() |
|
297 | 297 | { |
298 | - if ($this->_depend_<?= $depend[ 'variable' ] ?> === null) |
|
298 | + if ($this->_depend_<?= $depend['variable'] ?> === null) |
|
299 | 299 | { |
300 | - $this->_depend_<?= $depend[ 'variable' ] ?> = $this->findDependentRowset('<?= $objTables->getNamespace ( |
|
301 | - ) ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName ( $depend[ 'table' ] ) ?>'); |
|
300 | + $this->_depend_<?= $depend['variable'] ?> = $this->findDependentRowset('<?= $objTables->getNamespace( |
|
301 | + ) ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName($depend['table']) ?>'); |
|
302 | 302 | } |
303 | 303 | |
304 | - return $this->_depend_<?= $depend[ 'variable' ] ?>; |
|
304 | + return $this->_depend_<?= $depend['variable'] ?>; |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | <?php endforeach; ?> |
@@ -1,20 +1,20 @@ |
||
1 | 1 | <?="<?php\n"?> |
2 | 2 | |
3 | 3 | /** |
4 | - * <?=$this->config->last_modify."\n"?> |
|
4 | + * <?=$this->config->last_modify . "\n"?> |
|
5 | 5 | * |
6 | 6 | * @package <?=$this->config->namespace?>Model |
7 | 7 | * @subpackage Model |
8 | 8 | * @see Zend_Exception. <?="\n"?> |
9 | 9 | * |
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 | -class <?=$this->config->namespace?$this->config->namespace."_":""?>Model_EntityException extends Exception |
|
18 | +class <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>Model_EntityException extends Exception |
|
19 | 19 | { |
20 | 20 | } |
@@ -3,21 +3,21 @@ discard block |
||
3 | 3 | /** |
4 | 4 | * Application Model DbTables |
5 | 5 | * |
6 | - * <?=$this->config->last_modify."\n"?> |
|
6 | + * <?=$this->config->last_modify . "\n"?> |
|
7 | 7 | * |
8 | 8 | * Tabela definida por 'tablename' |
9 | 9 | * |
10 | 10 | * @package <?=$objTables->getNamespace()?><?="\n"?> |
11 | 11 | * @subpackage DbTable |
12 | - * @author <?=$this->config->author."\n"?> |
|
12 | + * @author <?=$this->config->author . "\n"?> |
|
13 | 13 | * |
14 | - * @copyright <?=$this->config->copyright."\n"?> |
|
15 | - * @license <?=$this->config->license."\n"?> |
|
16 | - * @link <?=$this->config->link."\n"?> |
|
17 | - * @version <?=$this->config->version."\n"?> |
|
14 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
15 | + * @license <?=$this->config->license . "\n"?> |
|
16 | + * @link <?=$this->config->link . "\n"?> |
|
17 | + * @version <?=$this->config->version . "\n"?> |
|
18 | 18 | */ |
19 | 19 | |
20 | -class <?=$objTables->getNamespace()?>_DbTable_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?> extends <?=$this->config->namespace?$this->config->namespace."_":""?>Model_<?=$objMakeFile->getFilesFixeds('parentClass')->getFileName() . "\n"?> |
|
20 | +class <?=$objTables->getNamespace()?>_DbTable_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?> extends <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>Model_<?=$objMakeFile->getFilesFixeds('parentClass')->getFileName() . "\n"?> |
|
21 | 21 | { |
22 | 22 | /** |
23 | 23 | * Nome da tabela do banco de dados |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @access protected |
27 | 27 | */ |
28 | 28 | protected $_name = '<?=$objTables->getName()?>'; |
29 | -<?php if($objTables->hasSchema()): ?> |
|
29 | +<?php if ($objTables->hasSchema()): ?> |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Schema da tabela do banco de dados |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | * @var string |
44 | 44 | * @access protected |
45 | 45 | */ |
46 | - protected $_rowClass = '<?=$objTables->getNamespace()?>_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?>'; |
|
46 | + protected $_rowClass = '<?=$objTables->getNamespace()?>_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?>'; |
|
47 | 47 | |
48 | -<?php if( $objTables->hasPrimaryKey() ):?> |
|
48 | +<?php if ($objTables->hasPrimaryKey()):?> |
|
49 | 49 | /** |
50 | 50 | * Nome da Primary Key |
51 | 51 | * |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | * @access protected |
54 | 54 | */ |
55 | 55 | protected $_primary = array( |
56 | -<?php foreach($objTables->getPrimaryKeys() as $pks):?> |
|
56 | +<?php foreach ($objTables->getPrimaryKeys() as $pks):?> |
|
57 | 57 | '<?=$pks->getName()?>', |
58 | 58 | <?php endforeach; ?> |
59 | 59 | ); |
60 | 60 | <?php endif ?> |
61 | -<?php if($this->config->{'folder-name'}):?> |
|
61 | +<?php if ($this->config->{'folder-name'}):?> |
|
62 | 62 | /** |
63 | 63 | * Initialize database adapter. |
64 | 64 | * |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | parent::_setupDatabaseAdapter(); |
74 | 74 | } |
75 | 75 | <?php endif ?> |
76 | -<?php if( $objTables->hasSequences() ) : ?> |
|
76 | +<?php if ($objTables->hasSequences()) : ?> |
|
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Definir a lógica para os novos valores na chave primária. |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @var mixed |
83 | 83 | */ |
84 | -<?php if ( 1 == count($objTables->getSequences() ) ) : ?> |
|
85 | -<?php if(strpos($this->config->driver, 'pgsql')): ?> |
|
86 | -<?php $seqs = $objTables->getSequences();reset($seqs);$seq = current($seqs);?> |
|
84 | +<?php if (1 == count($objTables->getSequences())) : ?> |
|
85 | +<?php if (strpos($this->config->driver, 'pgsql')): ?> |
|
86 | +<?php $seqs = $objTables->getSequences(); reset($seqs); $seq = current($seqs); ?> |
|
87 | 87 | protected $_sequence = '<?=$seq->getSequence() ?>'; |
88 | 88 | <?php else: ?> |
89 | 89 | protected $_sequence = true; |
@@ -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 | } |
@@ -16,88 +16,88 @@ 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 tabelas a serem ignoradas |
69 | - 'ignoreTable' => array () , |
|
69 | + 'ignoreTable' => array(), |
|
70 | 70 | ); |
71 | 71 | |
72 | 72 | /** |
73 | 73 | * @var string[] um array com todos os campos obrigatorios |
74 | 74 | */ |
75 | - protected $attRequered = array ( |
|
76 | - 'driver' => true , |
|
77 | - 'database' => true , |
|
78 | - 'host' => true , |
|
79 | - 'username' => true , |
|
75 | + protected $attRequered = array( |
|
76 | + 'driver' => true, |
|
77 | + 'database' => true, |
|
78 | + 'host' => true, |
|
79 | + 'username' => true, |
|
80 | 80 | 'path' => true |
81 | 81 | ); |
82 | 82 | |
83 | - protected $arrFunc = array (); |
|
83 | + protected $arrFunc = array(); |
|
84 | 84 | |
85 | - private $framworkFiles = array (); |
|
85 | + private $framworkFiles = array(); |
|
86 | 86 | |
87 | - public $reservedWord = array (); |
|
87 | + public $reservedWord = array(); |
|
88 | 88 | |
89 | - private static $dataTypesDefault = array ( |
|
90 | - 'int' => 'int' , |
|
91 | - 'float' => 'float' , |
|
92 | - 'string' => 'string' , |
|
93 | - 'text' => 'string' , |
|
94 | - 'date' => 'date' , |
|
95 | - 'datetime' => 'datetime' , |
|
96 | - 'timestamp' => 'timestamp' , |
|
89 | + private static $dataTypesDefault = array( |
|
90 | + 'int' => 'int', |
|
91 | + 'float' => 'float', |
|
92 | + 'string' => 'string', |
|
93 | + 'text' => 'string', |
|
94 | + 'date' => 'date', |
|
95 | + 'datetime' => 'datetime', |
|
96 | + 'timestamp' => 'timestamp', |
|
97 | 97 | 'boolean' => 'boolean' |
98 | 98 | ); |
99 | 99 | |
100 | - protected $dataTypes = array (); |
|
100 | + protected $dataTypes = array(); |
|
101 | 101 | |
102 | 102 | const SEPARETOR = ""; |
103 | 103 | |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @return bool |
108 | 108 | */ |
109 | - protected function checkConfig () |
|
109 | + protected function checkConfig() |
|
110 | 110 | { |
111 | - if ( array_diff_key ( $this->attRequered , array_filter ( $this->arrConfig ) ) ) |
|
111 | + if (array_diff_key($this->attRequered, array_filter($this->arrConfig))) |
|
112 | 112 | { |
113 | 113 | return false; |
114 | 114 | } |
@@ -121,33 +121,33 @@ discard block |
||
121 | 121 | * |
122 | 122 | * @return array |
123 | 123 | */ |
124 | - abstract protected function getParams (); |
|
124 | + abstract protected function getParams(); |
|
125 | 125 | |
126 | 126 | /** |
127 | 127 | * Popula as config do generater com as configuraçoes do framework |
128 | 128 | * |
129 | 129 | * @return mixed |
130 | 130 | */ |
131 | - abstract protected function parseFrameworkConfig (); |
|
131 | + abstract protected function parseFrameworkConfig(); |
|
132 | 132 | |
133 | 133 | /** |
134 | 134 | * Cria Instancias dos arquivos que devem ser gerados |
135 | 135 | * |
136 | 136 | * @return \Classes\AdapterMakerFile\AbstractAdapter[] |
137 | 137 | */ |
138 | - abstract public function getMakeFileInstances (); |
|
138 | + abstract public function getMakeFileInstances(); |
|
139 | 139 | |
140 | - abstract protected function init (); |
|
140 | + abstract protected function init(); |
|
141 | 141 | |
142 | 142 | /** |
143 | 143 | * retorna a base do Namespace |
144 | 144 | * |
145 | 145 | * @return array |
146 | 146 | */ |
147 | - protected function getBaseNamespace () |
|
147 | + protected function getBaseNamespace() |
|
148 | 148 | { |
149 | - return array ( |
|
150 | - $this->arrConfig[ 'namespace' ] , |
|
149 | + return array( |
|
150 | + $this->arrConfig['namespace'], |
|
151 | 151 | 'Model' |
152 | 152 | ); |
153 | 153 | } |
@@ -158,54 +158,54 @@ discard block |
||
158 | 158 | * @return mixed |
159 | 159 | */ |
160 | 160 | |
161 | - public function createClassNamespace ( $table ) |
|
161 | + public function createClassNamespace($table) |
|
162 | 162 | { |
163 | - $arrNames = $this->getBaseNamespace (); |
|
163 | + $arrNames = $this->getBaseNamespace(); |
|
164 | 164 | |
165 | - if ( isset( $this->arrConfig[ 'folder-database' ] ) |
|
166 | - && $this->arrConfig[ 'folder-database' ] |
|
165 | + if (isset($this->arrConfig['folder-database']) |
|
166 | + && $this->arrConfig['folder-database'] |
|
167 | 167 | ) |
168 | 168 | { |
169 | - $arrNames[] = AbstractMaker::getClassName ( $this->arrConfig[ 'driver' ] ); |
|
169 | + $arrNames[] = AbstractMaker::getClassName($this->arrConfig['driver']); |
|
170 | 170 | } |
171 | 171 | |
172 | - if ( isset( $this->arrConfig[ 'folder-name' ] ) |
|
173 | - && $this->arrConfig[ 'folder-name' ] |
|
172 | + if (isset($this->arrConfig['folder-name']) |
|
173 | + && $this->arrConfig['folder-name'] |
|
174 | 174 | ) |
175 | 175 | { |
176 | - $arrNames[] = AbstractMaker::getClassName ( $this->arrConfig[ 'folder-name' ] ); |
|
176 | + $arrNames[] = AbstractMaker::getClassName($this->arrConfig['folder-name']); |
|
177 | 177 | } |
178 | 178 | |
179 | - if ( $table->hasSchema () ) |
|
179 | + if ($table->hasSchema()) |
|
180 | 180 | { |
181 | - $arrNames[] = $this->replaceReservedWord ( AbstractMaker::getClassName ( $table->getSchema () ) ); |
|
181 | + $arrNames[] = $this->replaceReservedWord(AbstractMaker::getClassName($table->getSchema())); |
|
182 | 182 | } else |
183 | 183 | { |
184 | - $arrNames[] = $this->replaceReservedWord ( AbstractMaker::getClassName ( $table->getDatabase () ) ); |
|
184 | + $arrNames[] = $this->replaceReservedWord(AbstractMaker::getClassName($table->getDatabase())); |
|
185 | 185 | } |
186 | 186 | |
187 | - return implode ( static::SEPARETOR , array_filter ( $arrNames ) ); |
|
187 | + return implode(static::SEPARETOR, array_filter($arrNames)); |
|
188 | 188 | } |
189 | 189 | |
190 | - public function __construct ( $array ) |
|
190 | + public function __construct($array) |
|
191 | 191 | { |
192 | 192 | $this->dataTypes = $this->dataTypes + self::$dataTypesDefault; |
193 | - $array += array ( |
|
194 | - 'version' => Config::$version , |
|
195 | - 'author' => ucfirst ( get_current_user () ) , |
|
196 | - 'last_modify' => date ( "d-m-Y" ) |
|
193 | + $array += array( |
|
194 | + 'version' => Config::$version, |
|
195 | + 'author' => ucfirst(get_current_user()), |
|
196 | + 'last_modify' => date("d-m-Y") |
|
197 | 197 | ); |
198 | 198 | |
199 | - $this->setFrameworkFiles ( $array ); |
|
200 | - $this->parseFrameworkConfig (); |
|
201 | - $this->setParams ( $this->getParams () ); |
|
202 | - $this->setParams ( $array ); |
|
203 | - $this->init (); |
|
204 | - $this->validTableNames (); |
|
205 | - if ( ! $this->isValid () ) |
|
199 | + $this->setFrameworkFiles($array); |
|
200 | + $this->parseFrameworkConfig(); |
|
201 | + $this->setParams($this->getParams()); |
|
202 | + $this->setParams($array); |
|
203 | + $this->init(); |
|
204 | + $this->validTableNames(); |
|
205 | + if ( ! $this->isValid()) |
|
206 | 206 | { |
207 | - $var = array_diff_key ( $this->attRequered , array_filter ( $this->arrConfig ) ); |
|
208 | - throw new Exception( $var ); |
|
207 | + $var = array_diff_key($this->attRequered, array_filter($this->arrConfig)); |
|
208 | + throw new Exception($var); |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
@@ -214,43 +214,43 @@ discard block |
||
214 | 214 | * |
215 | 215 | * @param $array |
216 | 216 | */ |
217 | - public function setFrameworkFiles ( $array ) |
|
217 | + public function setFrameworkFiles($array) |
|
218 | 218 | { |
219 | - $this->framworkFiles[ 'library' ] = isset( $array[ 'framework-path-library' ] ) |
|
220 | - ? $array[ 'framework-path-library' ] : null; |
|
219 | + $this->framworkFiles['library'] = isset($array['framework-path-library']) |
|
220 | + ? $array['framework-path-library'] : null; |
|
221 | 221 | |
222 | - $this->framworkFiles[ 'ini' ] = isset( $array[ 'framework-ini' ] ) |
|
223 | - ? $array[ 'framework-ini' ] : null; |
|
222 | + $this->framworkFiles['ini'] = isset($array['framework-ini']) |
|
223 | + ? $array['framework-ini'] : null; |
|
224 | 224 | |
225 | - $this->framworkFiles[ 'environment' ] = isset( $array[ 'environment' ] ) |
|
226 | - ? $array[ 'environment' ] : 'production'; |
|
225 | + $this->framworkFiles['environment'] = isset($array['environment']) |
|
226 | + ? $array['environment'] : 'production'; |
|
227 | 227 | |
228 | 228 | } |
229 | 229 | |
230 | - protected function isValidFrameworkFiles () |
|
230 | + protected function isValidFrameworkFiles() |
|
231 | 231 | { |
232 | - if ( ! is_file ( $this->framworkFiles[ 'ini' ] ) ) |
|
232 | + if ( ! is_file($this->framworkFiles['ini'])) |
|
233 | 233 | { |
234 | 234 | return false; |
235 | 235 | } |
236 | 236 | |
237 | - if ( ! is_dir ( $this->framworkFiles[ 'library' ] ) ) |
|
237 | + if ( ! is_dir($this->framworkFiles['library'])) |
|
238 | 238 | { |
239 | 239 | return false; |
240 | 240 | } |
241 | 241 | |
242 | - if ( ! isset ( $this->framworkFiles[ 'environment' ] ) |
|
243 | - or empty( $this->framworkFiles[ 'environment' ] ) |
|
242 | + if ( ! isset ($this->framworkFiles['environment']) |
|
243 | + or empty($this->framworkFiles['environment']) |
|
244 | 244 | ) |
245 | 245 | { |
246 | 246 | return false; |
247 | 247 | } |
248 | - set_include_path ( |
|
249 | - implode ( |
|
250 | - PATH_SEPARATOR , |
|
251 | - array ( |
|
252 | - realpath ( $this->framworkFiles[ 'library' ] ) , |
|
253 | - get_include_path () , |
|
248 | + set_include_path( |
|
249 | + implode( |
|
250 | + PATH_SEPARATOR, |
|
251 | + array( |
|
252 | + realpath($this->framworkFiles['library']), |
|
253 | + get_include_path(), |
|
254 | 254 | ) |
255 | 255 | ) |
256 | 256 | ); |
@@ -258,119 +258,119 @@ discard block |
||
258 | 258 | return true; |
259 | 259 | } |
260 | 260 | |
261 | - protected function getFrameworkIni () |
|
261 | + protected function getFrameworkIni() |
|
262 | 262 | { |
263 | - return $this->framworkFiles[ 'ini' ]; |
|
263 | + return $this->framworkFiles['ini']; |
|
264 | 264 | } |
265 | 265 | |
266 | - protected function getEnvironment () |
|
266 | + protected function getEnvironment() |
|
267 | 267 | { |
268 | - return $this->framworkFiles[ 'environment' ]; |
|
268 | + return $this->framworkFiles['environment']; |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
272 | 272 | * Popula as variaveis de acordo com o arquivo de configuração do seu framework |
273 | 273 | */ |
274 | - protected function isValid () |
|
274 | + protected function isValid() |
|
275 | 275 | { |
276 | - return $this->checkConfig (); |
|
276 | + return $this->checkConfig(); |
|
277 | 277 | } |
278 | 278 | |
279 | - private function setParams ( $array ) |
|
279 | + private function setParams($array) |
|
280 | 280 | { |
281 | - if ( count ( $array ) > 0 ) |
|
281 | + if (count($array) > 0) |
|
282 | 282 | { |
283 | - $this->arrConfig = array_filter ( $array ) + $this->arrConfig; |
|
283 | + $this->arrConfig = array_filter($array) + $this->arrConfig; |
|
284 | 284 | } |
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
288 | 288 | * @return string |
289 | 289 | */ |
290 | - public function getDatabase () |
|
290 | + public function getDatabase() |
|
291 | 291 | { |
292 | - return $this->arrConfig[ 'database' ]; |
|
292 | + return $this->arrConfig['database']; |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
296 | 296 | * @return bool |
297 | 297 | */ |
298 | - public function hasSchemas () |
|
298 | + public function hasSchemas() |
|
299 | 299 | { |
300 | - return ! empty ( $this->arrConfig[ 'schema' ] ); |
|
300 | + return ! empty ($this->arrConfig['schema']); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
304 | 304 | * @return string[] |
305 | 305 | */ |
306 | - public function getSchemas () |
|
306 | + public function getSchemas() |
|
307 | 307 | { |
308 | - if ( is_string ( $this->arrConfig[ 'schema' ] ) ) |
|
308 | + if (is_string($this->arrConfig['schema'])) |
|
309 | 309 | { |
310 | - return array ( $this->arrConfig[ 'schema' ] ); |
|
310 | + return array($this->arrConfig['schema']); |
|
311 | 311 | } |
312 | 312 | |
313 | - return $this->arrConfig[ 'schema' ]; |
|
313 | + return $this->arrConfig['schema']; |
|
314 | 314 | } |
315 | 315 | |
316 | - public function setSchema ( $schema ) |
|
316 | + public function setSchema($schema) |
|
317 | 317 | { |
318 | - $this->arrConfig[ 'schema' ] = $schema; |
|
318 | + $this->arrConfig['schema'] = $schema; |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
322 | 322 | * @return string |
323 | 323 | */ |
324 | - public function getHost () |
|
324 | + public function getHost() |
|
325 | 325 | { |
326 | - return $this->arrConfig[ 'host' ]; |
|
326 | + return $this->arrConfig['host']; |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
330 | 330 | * @return int |
331 | 331 | */ |
332 | - public function getPort () |
|
332 | + public function getPort() |
|
333 | 333 | { |
334 | - return $this->arrConfig[ 'port' ]; |
|
334 | + return $this->arrConfig['port']; |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | /** |
338 | 338 | * @return boolean |
339 | 339 | */ |
340 | - public function hasPort () |
|
340 | + public function hasPort() |
|
341 | 341 | { |
342 | - return ! empty( $this->arrConfig[ 'port' ] ); |
|
342 | + return ! empty($this->arrConfig['port']); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | /** |
346 | 346 | * @return boolean |
347 | 347 | */ |
348 | - public function isCleanTrash(){ |
|
349 | - return (boolean) $this->arrConfig[ 'clean-trash' ]; |
|
348 | + public function isCleanTrash() { |
|
349 | + return (boolean) $this->arrConfig['clean-trash']; |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | /** |
353 | 353 | * @return string |
354 | 354 | */ |
355 | - public function getSocket () |
|
355 | + public function getSocket() |
|
356 | 356 | { |
357 | - return $this->arrConfig[ 'socket' ]; |
|
357 | + return $this->arrConfig['socket']; |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | /** |
361 | 361 | * @return string |
362 | 362 | */ |
363 | - public function getUser () |
|
363 | + public function getUser() |
|
364 | 364 | { |
365 | - return $this->arrConfig[ 'username' ]; |
|
365 | + return $this->arrConfig['username']; |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | /** |
369 | 369 | * @return string |
370 | 370 | */ |
371 | - public function getPassword () |
|
371 | + public function getPassword() |
|
372 | 372 | { |
373 | - return $this->arrConfig[ 'password' ]; |
|
373 | + return $this->arrConfig['password']; |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | /** |
@@ -378,11 +378,11 @@ discard block |
||
378 | 378 | * |
379 | 379 | * @return string |
380 | 380 | */ |
381 | - public function replaceReservedWord ( $palavra ) |
|
381 | + public function replaceReservedWord($palavra) |
|
382 | 382 | { |
383 | - if ( isset( $this->reservedWord[ strtolower ( $palavra ) ] ) ) |
|
383 | + if (isset($this->reservedWord[strtolower($palavra)])) |
|
384 | 384 | { |
385 | - return $this->reservedWord[ strtolower ( $palavra ) ]; |
|
385 | + return $this->reservedWord[strtolower($palavra)]; |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | return $palavra; |
@@ -391,15 +391,15 @@ discard block |
||
391 | 391 | /** |
392 | 392 | * @return bool |
393 | 393 | */ |
394 | - public function isStatusEnabled () |
|
394 | + public function isStatusEnabled() |
|
395 | 395 | { |
396 | - return (bool) $this->arrConfig[ 'status' ]; |
|
396 | + return (bool) $this->arrConfig['status']; |
|
397 | 397 | } |
398 | 398 | |
399 | - public function validTableNames () |
|
399 | + public function validTableNames() |
|
400 | 400 | { |
401 | - $matches = preg_grep ( '*\.*' , $this->getTablesName () ); |
|
402 | - if ( count ( $matches ) ) |
|
401 | + $matches = preg_grep('*\.*', $this->getTablesName()); |
|
402 | + if (count($matches)) |
|
403 | 403 | { |
404 | 404 | die("\033[0;31mError: Table name must not contain the schema.\033[0m\n"); |
405 | 405 | } |
@@ -408,28 +408,28 @@ discard block |
||
408 | 408 | /** |
409 | 409 | * @return bool |
410 | 410 | */ |
411 | - public function hasTablesName (){ |
|
412 | - return ! empty( $this->arrConfig[ 'tables' ] ); |
|
411 | + public function hasTablesName() { |
|
412 | + return ! empty($this->arrConfig['tables']); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | /** |
416 | 416 | * @return string[] |
417 | 417 | */ |
418 | - public function getTablesName () |
|
418 | + public function getTablesName() |
|
419 | 419 | { |
420 | - if ( is_string ( $this->arrConfig[ 'tables' ] ) ) |
|
420 | + if (is_string($this->arrConfig['tables'])) |
|
421 | 421 | { |
422 | - return array ( $this->arrConfig[ 'tables' ] ); |
|
422 | + return array($this->arrConfig['tables']); |
|
423 | 423 | } |
424 | 424 | |
425 | - return $this->arrConfig[ 'tables' ]; |
|
425 | + return $this->arrConfig['tables']; |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | /** |
429 | 429 | * @return string |
430 | 430 | */ |
431 | - public function getListTablesName(){ |
|
432 | - $str = implode("','", $this->getTablesName() ); |
|
431 | + public function getListTablesName() { |
|
432 | + $str = implode("','", $this->getTablesName()); |
|
433 | 433 | return "'$str'"; |
434 | 434 | } |
435 | 435 | |
@@ -438,25 +438,25 @@ discard block |
||
438 | 438 | * |
439 | 439 | * @return string |
440 | 440 | */ |
441 | - public function __get ( $str ) |
|
441 | + public function __get($str) |
|
442 | 442 | { |
443 | - $arr = array ( |
|
444 | - 'namespace' , |
|
445 | - 'framework' , |
|
446 | - 'author' , |
|
447 | - 'license' , |
|
448 | - 'version' , |
|
449 | - 'copyright' , |
|
450 | - 'link' , |
|
451 | - 'last_modify' , |
|
452 | - 'path' , |
|
453 | - 'folder-database' , |
|
443 | + $arr = array( |
|
444 | + 'namespace', |
|
445 | + 'framework', |
|
446 | + 'author', |
|
447 | + 'license', |
|
448 | + 'version', |
|
449 | + 'copyright', |
|
450 | + 'link', |
|
451 | + 'last_modify', |
|
452 | + 'path', |
|
453 | + 'folder-database', |
|
454 | 454 | 'folder-name' |
455 | 455 | ); |
456 | 456 | |
457 | - if ( in_array ( $str , $arr ) ) |
|
457 | + if (in_array($str, $arr)) |
|
458 | 458 | { |
459 | - return $this->arrConfig[ strtolower ( $str ) ]; |
|
459 | + return $this->arrConfig[strtolower($str)]; |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | return; |
@@ -467,9 +467,9 @@ discard block |
||
467 | 467 | * |
468 | 468 | * @return string |
469 | 469 | */ |
470 | - public static function convertTypeToPHP ( $type ) |
|
470 | + public static function convertTypeToPHP($type) |
|
471 | 471 | { |
472 | - return self::$dataTypesDefault[ $type ]; |
|
472 | + return self::$dataTypesDefault[$type]; |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | /** |
@@ -477,8 +477,8 @@ discard block |
||
477 | 477 | * |
478 | 478 | * @return string |
479 | 479 | */ |
480 | - public function convertTypeToTypeFramework ( $type ) |
|
480 | + public function convertTypeToTypeFramework($type) |
|
481 | 481 | { |
482 | - return $this->dataTypes[ $type ]; |
|
482 | + return $this->dataTypes[$type]; |
|
483 | 483 | } |
484 | 484 | } |