m170603_122711_CreateInvitationTable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 39
rs 10
c 0
b 0
f 0
ccs 0
cts 19
cp 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 20 2
A down() 0 4 1
1
<?php
2
3
/**
4
 *  _   __ __ _____ _____ ___  ____  _____
5
 * | | / // // ___//_  _//   ||  __||_   _|
6
 * | |/ // /(__  )  / / / /| || |     | |
7
 * |___//_//____/  /_/ /_/ |_||_|     |_|
8
 * @link https://vistart.me/
9
 * @copyright Copyright (c) 2016 - 2017 vistart
10
 * @license https://vistart.me/license/
11
 */
12
13
namespace rhosocial\user\models\invitation\migrations;
14
15
use rhosocial\user\migrations\Migration;
16
use rhosocial\user\models\invitation\Invitation;
17
use rhosocial\user\User;
18
19
/**
20
 * Class m170603_122711_CreateInvitationTable
21
 * @package rhosocial\user\models\invitation\migrations
22
 * @version 1.0
23
 * @author vistart <[email protected]>
24
 */
25
class m170603_122711_CreateInvitationTable extends Migration
26
{
27
    public function up()
28
    {
29
        $tableOptions = null;
0 ignored issues
show
Unused Code introduced by
$tableOptions is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
30
        if ($this->db->driverName == 'mysql') {
31
            // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
32
            $tableOptions = "CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB COMMENT='User Invitation'";
33
            $this->createTable(Invitation::tableName(), [
34
                'guid' => $this->varbinary(16)->notNull()->comment('GUID'),
35
                'user_guid' => $this->varbinary(16)->notNull()->comment('User GUID'),
36
                'content' => $this->integer(11)->notNull()->comment('Invitation Type'),
37
                'invitee_guid' => $this->varbinary(16)->notNull()->comment('Invitee GUID'),
38
                'ip' => $this->varbinary(16)->defaultValue(0)->notNull()->comment('IP Address'),
39
                'ip_type' => $this->smallInteger()->defaultValue(4)->notNull()->comment('IP Address Type'),
40
                'created_at' => $this->dateTime()->notNull()->defaultValue('1970-01-01 00:00:00')->comment('Created At'),
41
            ], $tableOptions);
42
        }
43
        $this->addPrimaryKey('user_invitation_guid_pk', Invitation::tableName(), 'guid');
44
        $this->addForeignKey('user_invitation_fk', Invitation::tableName(), 'user_guid', User::tableName(), 'guid', 'CASCADE', 'CASCADE');
45
        $this->addForeignKey('user_invitee_fk', Invitation::tableName(), 'invitee_guid', User::tableName(), 'guid', 'CASCADE', 'CASCADE');
46
    }
47
48
    public function down()
49
    {
50
        $this->dropTable(Invitation::tableName());
51
    }
52
53
    /*
54
    // Use safeUp/safeDown to run migration code within a transaction
55
    public function safeUp()
56
    {
57
    }
58
59
    public function safeDown()
60
    {
61
    }
62
    */
63
}
64