Completed
Pull Request — master (#186)
by Vladimir
16:33 queued 13:26
created

MakeInvitationsBetter   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 44
Duplicated Lines 93.18 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 41
loc 44
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B change() 41 41 1

How to fix   Duplicated Code   

Duplicated Code

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
2
3
use Phinx\Migration\AbstractMigration;
4
5
class MakeInvitationsBetter extends AbstractMigration
6
{
7 View Code Duplication
    public function change()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
8
    {
9
        $invitationsTable = $this->table('invitations');
10
        $invitationsTable
11
            ->addColumn('sent', 'datetime', [
12
                'after' => 'team',
13
                'null' => true,
14
                'default' => null,
15
                'comment' => 'When the invitation was sent',
16
            ])
17
            ->addColumn('status', 'integer', [
18
                'after' => 'text',
19
                'null' => false,
20
                'default' => 0,
21
                'signed' => true,
22
                'length' => 1,
23
                'comment' => '0: pending; 1: accepted; 2: rejected',
24
            ])
25
            ->addColumn('is_deleted', 'boolean', [
26
                'after' => 'status',
27
                'null' => false,
28
                'default' => false,
29
                'comment' => 'Whether or not the invitation has been soft deleted',
30
            ])
31
            ->update()
32
        ;
33
34
        $invitationsTable
35
            ->renameColumn('text', 'message')
36
            ->update()
37
        ;
38
39
        $invitationsTable
40
            ->changeColumn('message', 'text', [
41
                'null' => true,
42
                'default' => null,
43
                'comment' => 'The message sent when inviting a player to a team',
44
            ])
45
            ->update()
46
        ;
47
    }
48
}
49