Conditions | 1 |
Paths | 1 |
Total Lines | 27 |
Code Lines | 19 |
Lines | 27 |
Ratio | 100 % |
Changes | 0 |
1 | <?php |
||
7 | public function up() |
||
8 | { |
||
9 | $playersTable = $this->table('players'); |
||
10 | $playersTable |
||
11 | ->addColumn('is_disabled', 'boolean', [ |
||
12 | 'after' => 'last_login', |
||
13 | 'null' => false, |
||
14 | 'default' => false, |
||
15 | 'comment' => 'Whether or not this account has been disabled by an admin and cannot log in', |
||
16 | ]) |
||
17 | ->addColumn('is_deleted', 'boolean', [ |
||
18 | 'after' => 'is_disabled', |
||
19 | 'null' => false, |
||
20 | 'default' => false, |
||
21 | 'comment' => 'Whether or not this player has been soft-deleted', |
||
22 | ]) |
||
23 | ->update() |
||
24 | ; |
||
25 | |||
26 | $this->query("UPDATE players SET is_deleted = 1 WHERE status = 'deleted';"); |
||
27 | $this->query("UPDATE players SET is_disabled = 1 WHERE status = 'disabled';"); |
||
28 | |||
29 | $playersTable |
||
30 | ->removeColumn('status') |
||
31 | ->update() |
||
32 | ; |
||
33 | } |
||
34 | |||
58 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.