| Conditions | 5 |
| Paths | 5 |
| Total Lines | 64 |
| Code Lines | 41 |
| Lines | 0 |
| Ratio | 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 |
||
| 84 | [ 'updateSchema', 'oldimage', 'oldimage varchar', 'patch-oldimage-schema.sql' ], |
||
| 85 | [ 'updateSchema', 'filearchive', 'filearchive varchar', 'patch-filearchive-schema.sql' ], |
||
| 86 | [ 'updateSchema', 'image', 'image varchar', 'patch-image-schema.sql' ] |
||
| 87 | ]; |
||
| 88 | } |
||
| 89 | |||
| 90 | protected function applyPatch( $path, $isFullPath = false, $msg = null ) { |
||
| 91 | $prevScroll = $this->db->scrollableCursor( false ); |
||
| 92 | $prevPrep = $this->db->prepareStatements( false ); |
||
| 93 | parent::applyPatch( $path, $isFullPath, $msg ); |
||
| 94 | $this->db->scrollableCursor( $prevScroll ); |
||
| 95 | $this->db->prepareStatements( $prevPrep ); |
||
| 96 | } |
||
| 97 | |||
| 98 | /** |
||
| 99 | * General schema update for a table that touches more than one field or requires |
||
| 100 | * destructive actions (such as dropping and recreating the table). |
||
| 101 | * |
||
| 102 | * @param string $table |
||
| 103 | * @param string $updatekey |
||
| 104 | * @param string $patch |
||
| 105 | * @param bool $fullpath |
||
| 106 | */ |
||
| 107 | protected function updateSchema( $table, $updatekey, $patch, $fullpath = false ) { |
||
| 108 | if ( !$this->db->tableExists( $table, __METHOD__ ) ) { |
||
| 109 | $this->output( "...$table table does not exist, skipping schema update patch.\n" ); |
||
| 110 | } elseif ( $this->updateRowExists( $updatekey ) ) { |
||
| 111 | $this->output( "...$table already had schema updated by $patch.\n" ); |
||
| 112 | } else { |
||
| 113 | $this->insertUpdateRow( $updatekey ); |
||
| 114 | |||
| 115 | return $this->applyPatch( $patch, $fullpath, "Updating schema of table $table" ); |
||
| 116 | } |
||
| 117 | |||
| 118 | return true; |
||
| 119 | } |
||
| 120 | } |
||
| 121 |