Schema::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 1 Features 0
Metric Value
c 4
b 1
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
/**
3
 * @author   Temitope Olotin <[email protected]>
4
 * @license  <https://opensource.org/license/MIT> MIT
5
 */
6
namespace Laztopaz\EmojiRestfulAPI;
7
8
use Illuminate\Database\Capsule\Manager as Capsule;
9
10
class Schema
11
{
12
    /**
13
     * This method migrates all database schema when this class is instatiated.
14
     */
15
    public function __construct()
16
    {
17
        $this->createUser();
18
        $this->createKeyword();
19
        $this->createCategory();
20
        $this->createEmoji();
21
    }
22
23
    /**
24
     * This method create users schema.
25
     */
26 View Code Duplication
    public function createUser()
0 ignored issues
show
Duplication introduced by
This method 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...
27
    {
28
        if (! Capsule::schema()->hasTable('users')) {
29
            Capsule::schema()->create('users', function ($table) {
30
                $table->increments('id');
31
                $table->string('firstname');
32
                $table->string('lastname');
33
                $table->string('username');
34
                $table->string('password');
35
                $table->string('email')->unique();
36
                $table->timestamps();
37
            });
38
        }
39
    }
40
41
    /**
42
     * This method creates keyword schema.
43
     */
44 View Code Duplication
    public function createKeyword()
0 ignored issues
show
Duplication introduced by
This method 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...
45
    {
46
        if (! Capsule::schema()->hasTable('keywords')) {
47
            Capsule::schema()->create('keywords', function ($table) {
48
                $table->increments('id');
49
                $table->integer('emoji_id');
50
                $table->string('keyword_name');
51
                $table->timestamps();
52
            });
53
        }
54
    }
55
56
    /**
57
     * This method creates emoji category schema.
58
     */
59 View Code Duplication
    public function createCategory()
0 ignored issues
show
Duplication introduced by
This method 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...
60
    {
61
        if (! Capsule::schema()->hasTable('categories')) {
62
            Capsule::schema()->create('categories', function ($table) {
63
                $table->increments('id');
64
                $table->string('category_name');
65
                $table->timestamps();
66
            });
67
        }
68
    }
69
70
    /**
71
     * This method creates emoji  schema.
72
     */
73 View Code Duplication
    public function createEmoji()
0 ignored issues
show
Duplication introduced by
This method 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...
74
    {
75
        if (! Capsule::schema()->hasTable('emojis')) {
76
            Capsule::schema()->create('emojis', function ($table) {
77
                $table->increments('id');
78
                $table->string('name');
79
                $table->string('char');
80
                $table->string('category');
81
                $table->string('created_by');
82
                $table->timestamps();
83
            });
84
        }
85
    }
86
}
87