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 Postgres96 extends Postgres |
||
|
1 ignored issue
–
show
|
|||
| 14 | { |
||
| 15 | public $typIndexes = ['BTREE', 'BRIN', 'RTREE', 'GIST', 'GIN', 'HASH', 'SP-GIST']; |
||
| 16 | public $major_version = 9.6; |
||
| 17 | |||
| 18 | // Administration functions |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Returns all available process information. |
||
| 22 | * |
||
| 23 | * @param null|string $database (optional) Find only connections to specified database |
||
| 24 | * |
||
| 25 | * @return \PHPPgAdmin\ADORecordSet A recordset |
||
| 26 | */ |
||
| 27 | View Code Duplication | public function getProcesses($database = null) |
|
| 51 | |||
| 52 | public function hasUserSignals() |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Creates a new user. As of PG 9.6, CREATEUSER privilege has been deprecated. |
||
| 59 | * |
||
| 60 | * @see {@link https://www.postgresql.org/docs/9.6/static/sql-createrole.html} |
||
| 61 | * |
||
| 62 | * @param string $username The username of the user to create |
||
| 63 | * @param string $password A password for the user |
||
| 64 | * @param bool $createdb boolean Whether or not the user can create databases |
||
| 65 | * @param bool $createrole boolean Whether or not the user can create other users |
||
| 66 | * @param string $expiry string Format 'YYYY-MM-DD HH:MM:SS'. '' means never expire |
||
| 67 | * @param array $groups The groups to create the user in |
||
| 68 | * |
||
| 69 | * @return int 0 if operation was successful |
||
| 70 | * |
||
| 71 | * @internal param $group (array) The groups to create the user in |
||
| 72 | */ |
||
| 73 | View Code Duplication | public function createUser($username, $password, $createdb, $createrole, $expiry, $groups) |
|
| 100 | } |
||
| 101 |
This check marks property names that have not been written in camelCase.
In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes
databaseConnectionString.