Completed
Push — master ( d1abb9...2c5b6e )
by Ricardo
02:02
created

CreateOauthAccessTokensTable   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
dl 58
loc 58
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A up() 13 13 1
A down() 4 4 1
A getConnection() 4 4 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 Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Support\Facades\Schema;
6
7 View Code Duplication
class CreateOauthAccessTokensTable extends Migration
0 ignored issues
show
Duplication introduced by
This class 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
    /**
10
     * The database schema.
11
     *
12
     * @var \Illuminate\Database\Schema\Builder
13
     */
14
    protected $schema;
15
16
    /**
17
     * Create a new migration instance.
18
     *
19
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
20
     */
21
    public function __construct()
22
    {
23
        $this->schema = Schema::connection($this->getConnection());
24
    }
25
26
    /**
27
     * Run the migrations.
28
     *
29
     * @return void
30
     */
31
    public function up()
32
    {
33
        $this->schema->create('oauth_access_tokens', function (Blueprint $table) {
34
            $table->string('id', 100)->primary();
35
            $table->unsignedBigInteger('user_id')->nullable()->index();
36
            $table->unsignedBigInteger('client_id');
37
            $table->string('name')->nullable();
38
            $table->text('scopes')->nullable();
39
            $table->boolean('revoked');
40
            $table->timestamps();
41
            $table->dateTime('expires_at')->nullable();
42
        });
43
    }
44
45
    /**
46
     * Reverse the migrations.
47
     *
48
     * @return void
49
     */
50
    public function down()
51
    {
52
        $this->schema->dropIfExists('oauth_access_tokens');
53
    }
54
55
    /**
56
     * Get the migration connection name.
57
     *
58
     * @return string|null
59
     */
60
    public function getConnection()
61
    {
62
        return config('passport.storage.database.connection');
63
    }
64
}
65