Passed
Push — master ( fde606...0af3c0 )
by Armando
08:21
created

CreateUserTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 10 1
A down() 0 3 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
declare(strict_types=1);
4
5
use Illuminate\Database\Migrations\Migration;
6
use Illuminate\Database\Schema\Blueprint;
7
use Illuminate\Support\Facades\Schema;
8
9
class CreateUserTable extends Migration
10
{
11
    public function up(): void
12
    {
13
        Schema::create('user', static function (Blueprint $table) {
14
            $table->bigInteger('id')->primary()->comment('Unique user identifier');
15
            $table->boolean('is_bot')->nullable()->default(0)->comment('True if this user is a bot');
16
            $table->char('first_name')->default('')->comment('User\'s first name');
17
            $table->char('last_name')->nullable()->comment('User\'s last name');
18
            $table->char('username', 191)->nullable()->index('username')->comment('User\'s username');
19
            $table->char('language_code', 10)->nullable()->comment('User\'s system language');
20
            $table->timestamps();
21
        });
22
    }
23
24
    public function down(): void
25
    {
26
        Schema::dropIfExists('user');
27
    }
28
}
29