Conditions | 11 |
Paths | 25 |
Total Lines | 73 |
Code Lines | 42 |
Lines | 41 |
Ratio | 56.16 % |
Changes | 9 | ||
Bugs | 3 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
156 | * Retorna o Nome da Sequence da tabela |
||
157 | * |
||
158 | * @param $table |
||
159 | * @param $column |
||
160 | * |
||
161 | * @return string |
||
162 | */ |
||
163 | public function getSequence ( $table , $column ) |
||
164 | { |
||
165 | $pdo = $this->getPDO (); |
||
166 | $return1 = $pdo->query ( "SELECT pg_get_serial_sequence('$table', '$column');" ) |
||
167 | ->fetchColumn (); |
||
168 | |||
169 | if ( $return1 ) |
||
170 | { |
||
171 | return $return1; |
||
172 | } |
||
173 | |||
174 | $dtbase = explode ( '.' , $table );; |
||
175 | |||
176 | $stmt = $pdo->prepare ( |
||
177 | "SELECT adsrc FROM pg_attrdef AS att |
||
178 | INNER JOIN pg_class AS c |
||
179 | ON adrelid = c.oid AND att.adnum=1 AND c.relname = ? |
||
180 | INNER JOIN pg_catalog.pg_namespace n |
||
181 | ON n.oid = c.relnamespace and n.nspname=?" |
||
182 | ); |
||
183 | |||
184 | $schema = isset( $dtbase[ 1 ] ) ? $dtbase[ 1 ] : 'public'; |
||
185 | |||
186 | $stmt->bindParam ( 1 , $schema ); |
||
187 | $stmt->bindParam ( 2 , $dtbase[ 0 ] ); |
||
188 | $stmt->execute (); |
||
189 | $return2 = $stmt->fetchColumn (); |
||
190 | if ( $return2 ) |
||
191 | { |
||
192 | return preg_filter ( |
||
193 | array ( |
||
194 | '/nextval\(\'/' , |
||
195 | '/\'::regclass\)/' |
||
196 | ) , '' , $return2 |
||
197 | ); |
||
198 | } |
||
199 | |||
200 | } |
||
201 | |||
202 | /** |
||
203 | * @inheritDoc |
||
204 | */ |
||
205 | View Code Duplication | public function parseTables () |
|
206 | { |
||
207 | if ( $this->hasTables () ) |
||
208 | { |
||
209 | return $this->getAllTables (); |
||
210 | } |
||
211 | |||
212 | foreach ( $this->getListColumns () as $table ) |
||
213 | { |
||
214 | $schema = $table[ 'table_schema' ]; |
||
215 | $key = $table [ 'table_name' ]; |
||
216 | if ( ! $this->hasTable ( $key , $schema ) ) |
||
217 | { |
||
218 | $this->createTable ( $key , $schema ); |
||
219 | } |
||
220 | |||
221 | $column = Column::getInstance () |
||
222 | ->populate ( |
||
223 | array ( |
||
224 | 'name' => $table [ 'column_name' ] , |
||
225 | 'type' => $this->convertTypeToPhp ( $table[ 'data_type' ] ) , |
||
226 | 'nullable' => ( $table[ 'is_nullable' ] == 'YES' ) , |
||
227 | 'max_length' => $table[ 'max_length' ] |
||
228 | ) |
||
229 | ); |
||
291 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.