Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 13 | class postgres_index extends \phpbb\db\migration\migration |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * Do not run this migration if the DB is not PostgreSQL |
||
| 17 | * |
||
| 18 | * @return bool |
||
| 19 | */ |
||
| 20 | public function effectively_installed() |
||
| 21 | { |
||
| 22 | return $this->db->get_sql_layer() !== 'postgres' || $this->config->offsetExists('pst_postgres_ts_name'); |
||
| 23 | } |
||
| 24 | |||
| 25 | public static function depends_on() |
||
| 29 | |||
| 30 | public function update_data() |
||
| 41 | |||
| 42 | View Code Duplication | public function revert_data() |
|
| 51 | |||
| 52 | /** |
||
| 53 | * Create PostgreSQL FULLTEXT index for the topic_title |
||
| 54 | */ |
||
| 55 | public function create_postgres_index() |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Drop the PostgreSQL FULLTEXT index on phpbb_topics.topic_title |
||
| 64 | */ |
||
| 65 | public function drop_postgres_changes() |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Get an instance of the similartopics POSTGRES driver |
||
| 78 | * |
||
| 79 | * @return \vse\similartopics\driver\postgres |
||
| 80 | */ |
||
| 81 | protected function get_driver() |
||
| 85 | |||
| 86 | protected function get_ts_name() |
||
| 90 | } |
||
| 91 |