| Conditions | 1 |
| Paths | 1 |
| Total Lines | 75 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 7 | public function up() |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * User |
||
| 11 | */ |
||
| 12 | |||
| 13 | $this->createTable('{{%user}}', [ |
||
| 14 | 'id' => $this->primaryKey(), |
||
| 15 | 'email' => $this->string()->null()->unique(), |
||
| 16 | 'password' => $this->string()->notNull()->defaultValue(''), |
||
| 17 | 'password_reset_token' => $this->string()->null()->unique(), |
||
| 18 | 'email_confirm_token' => $this->string()->null()->unique(), |
||
| 19 | 'auth_key' => $this->string(32)->notNull()->defaultValue(''), |
||
| 20 | 'date_confirm' => $this->timestamp()->null(), |
||
| 21 | 'date_create' => $this->timestamp()->null(), |
||
| 22 | 'date_update' => $this->timestamp()->null(), |
||
| 23 | 'date_login' => $this->timestamp()->null(), |
||
| 24 | 'ip' => $this->bigInteger(20)->notNull()->defaultValue(0), |
||
| 25 | 'role_name' => $this->string(64)->notNull()->defaultValue(''), |
||
| 26 | 'status' => 'tinyint NOT NULL DEFAULT 0', |
||
| 27 | 'allowance' => $this->integer()->notNull()->defaultValue(0), |
||
| 28 | 'allowance_updated_at' => $this->integer()->notNull()->defaultValue(0), |
||
| 29 | ], $this->tableOptions); |
||
| 30 | |||
| 31 | $this->createIndex('role_name', '{{%user}}', 'role_name'); |
||
| 32 | $this->createIndex('status', '{{%user}}', 'status'); |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Profile |
||
| 36 | */ |
||
| 37 | |||
| 38 | $this->createTable('{{%user_profile}}', [ |
||
| 39 | 'user_id' => $this->primaryKey(), |
||
| 40 | 'full_name' => $this->string(40)->notNull()->defaultValue(''), |
||
| 41 | 'photo' => $this->string()->notNull()->defaultValue(''), |
||
| 42 | ], $this->tableOptions); |
||
| 43 | |||
| 44 | $this->addForeignKey( |
||
| 45 | 'fk_user_profile__user_id__user_id', |
||
| 46 | '{{%user_profile}}', |
||
| 47 | 'user_id', |
||
| 48 | '{{%user}}', |
||
| 49 | 'id', |
||
| 50 | 'CASCADE', |
||
| 51 | 'CASCADE' |
||
| 52 | ); |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Provider |
||
| 56 | */ |
||
| 57 | |||
| 58 | $this->createTable('{{%user_provider}}', [ |
||
| 59 | 'id' => $this->primaryKey(), |
||
| 60 | 'user_id' => $this->integer()->notNull()->defaultValue(0), |
||
| 61 | 'type' => 'tinyint NOT NULL DEFAULT 0', |
||
| 62 | 'profile_id' => $this->string()->notNull()->defaultValue(''), |
||
| 63 | 'profile_url' => $this->string()->notNull()->defaultValue(''), |
||
| 64 | 'access_token' => $this->string()->notNull()->defaultValue(''), |
||
| 65 | 'access_token_secret' => $this->string()->notNull()->defaultValue(''), |
||
| 66 | ], $this->tableOptions); |
||
| 67 | |||
| 68 | $this->createIndex('user_id', '{{%user_provider}}', 'user_id'); |
||
| 69 | $this->createIndex('provider_profile', '{{%user_provider}}', 'type, profile_id'); |
||
| 70 | $this->createIndex('user_provider', '{{%user_provider}}', 'user_id, type'); |
||
| 71 | |||
| 72 | $this->addForeignKey( |
||
| 73 | 'fk_user_provider', |
||
| 74 | '{{%user_provider}}', |
||
| 75 | 'user_id', |
||
| 76 | '{{%user}}', |
||
| 77 | 'id', |
||
| 78 | 'CASCADE', |
||
| 79 | 'CASCADE' |
||
| 80 | ); |
||
| 81 | } |
||
| 82 | |||
| 90 |