Passed
Branch master (c62005)
by ABDULMALIK
02:15
created

CreatePermission   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A change() 0 10 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
/**
6
 * Class CreatePermission
7
 */
8
class CreatePermission extends AbstractMigration
9
{
10
    /**
11
     * Create permission table in database.
12
     * Field 'name' is unique index.
13
     */
14
    public function change()
15
    {
16
        $permissionTable = $this->table('permission', ['signed' => false]);
17
18
        $permissionTable->addColumn('name', 'string', ['limit' => 100])
19
            ->addColumn('status', 'boolean', ['default' => true])
20
            ->addColumn('created_at', 'datetime')
21
            ->addColumn('updated_at', 'datetime', ['null' => true])
22
            ->addIndex('name', ['name' => 'idx_permission_name' ,'unique' => true])
23
            ->create();
24
    }
25
}
26