LaraCedServiceProvider   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 72
Duplicated Lines 20.83 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B register() 15 64 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
namespace LaraCed;
4
5
use Illuminate\Support\ServiceProvider;
6
use Illuminate\Database\Schema\Blueprint;
7
8
class LaraCedServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Register the service provider.
12
     *
13
     * @return void
14
     */
15
    public function register()
16
    {
17
        $userClass = config('auth.providers.users.model');
18
19
        $userClass = new $userClass;
20
21
        $userModel = $userClass->getTable();
22
23
        Blueprint::macro('ced', function () {
24
            $this->unsignedInteger('created_by')->nullable()->index();
0 ignored issues
show
Bug introduced by
The method unsignedInteger() does not seem to exist on object<LaraCed\LaraCedServiceProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
25
            $this->unsignedInteger('updated_by')->nullable()->index();
0 ignored issues
show
Bug introduced by
The method unsignedInteger() does not seem to exist on object<LaraCed\LaraCedServiceProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
26
            $this->unsignedInteger('deleted_by')->nullable()->index();
0 ignored issues
show
Bug introduced by
The method unsignedInteger() does not seem to exist on object<LaraCed\LaraCedServiceProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
27
        });
28
29
        Blueprint::macro('creator', function ($name = 'created_by') {
30
            $this->unsignedInteger($name)->nullable()->index();
0 ignored issues
show
Bug introduced by
The method unsignedInteger() does not seem to exist on object<LaraCed\LaraCedServiceProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
31
        });
32
        Blueprint::macro('editor', function ($name = 'updated_by') {
33
            $this->unsignedInteger($name)->nullable()->index();
0 ignored issues
show
Bug introduced by
The method unsignedInteger() does not seem to exist on object<LaraCed\LaraCedServiceProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
34
        });
35
        Blueprint::macro('destroyer', function ($name = 'deleted_by') {
36
            $this->unsignedInteger($name)->nullable()->index();
0 ignored issues
show
Bug introduced by
The method unsignedInteger() does not seem to exist on object<LaraCed\LaraCedServiceProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
37
        });
38
39
        Blueprint::macro('dropCed', function () {
40
            $this->dropColumn(['created_by', 'updated_by', 'deleted_by']);
0 ignored issues
show
Bug introduced by
The method dropColumn() does not seem to exist on object<LaraCed\LaraCedServiceProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
41
        });
42
43
        Blueprint::macro('cedForeign', function () use ($userModel) {
44
            $tableName = $this->getTable();
0 ignored issues
show
Bug introduced by
The method getTable() does not seem to exist on object<LaraCed\LaraCedServiceProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
45
46
            $this->foreign('created_by', 'fk_' . $tableName . 'has_created_by')->references('id')->on($userModel)->onUpdate('NO ACTION')->onDelete('NO ACTION');
0 ignored issues
show
Bug introduced by
The method foreign() does not seem to exist on object<LaraCed\LaraCedServiceProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
47
48
            $this->foreign('updated_by', 'fk_' . $tableName . 'has_updated_by')->references('id')->on($userModel)->onUpdate('NO ACTION')->onDelete('NO ACTION');
0 ignored issues
show
Bug introduced by
The method foreign() does not seem to exist on object<LaraCed\LaraCedServiceProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
49
50
            $this->foreign('deleted_by', 'fk_' . $tableName . 'has_deleted_by')->references('id')->on($userModel)->onUpdate('NO ACTION')->onDelete('NO ACTION');
0 ignored issues
show
Bug introduced by
The method foreign() does not seem to exist on object<LaraCed\LaraCedServiceProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
51
        });
52
53 View Code Duplication
        Blueprint::macro('creatorForeign', function ($name = 'created_by') use ($userModel) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
54
            $tableName = $this->getTable();
0 ignored issues
show
Bug introduced by
The method getTable() does not seem to exist on object<LaraCed\LaraCedServiceProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
55
56
            $this->foreign($name, 'fk_' . $tableName . 'has_' . $name)->references('id')->on($userModel)->onUpdate('NO ACTION')->onDelete('NO ACTION');
0 ignored issues
show
Bug introduced by
The method foreign() does not seem to exist on object<LaraCed\LaraCedServiceProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
57
        });
58
59 View Code Duplication
        Blueprint::macro('editorForeign', function ($name = 'updated_by') use ($userModel) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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
            $tableName = $this->getTable();
0 ignored issues
show
Bug introduced by
The method getTable() does not seem to exist on object<LaraCed\LaraCedServiceProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
61
62
            $this->foreign($name, 'fk_' . $tableName . 'has_' . $name)->references('id')->on($userModel)->onUpdate('NO ACTION')->onDelete('NO ACTION');
0 ignored issues
show
Bug introduced by
The method foreign() does not seem to exist on object<LaraCed\LaraCedServiceProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
63
        });
64
65 View Code Duplication
        Blueprint::macro('destroyerForeign', function ($name = 'deleted_by') use ($userModel) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
66
            $tableName = $this->getTable();
0 ignored issues
show
Bug introduced by
The method getTable() does not seem to exist on object<LaraCed\LaraCedServiceProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
67
68
            $this->foreign($name, 'fk_' . $tableName . 'has_' . $name)->references('id')->on($userModel)->onUpdate('NO ACTION')->onDelete('NO ACTION');
0 ignored issues
show
Bug introduced by
The method foreign() does not seem to exist on object<LaraCed\LaraCedServiceProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
69
        });
70
71
        Blueprint::macro('dropCedForeign', function () use ($userModel) {
72
            $tableName = $this->getTable();
0 ignored issues
show
Bug introduced by
The method getTable() does not seem to exist on object<LaraCed\LaraCedServiceProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
73
74
            $this->dropForeign('fk_' . $tableName . '_has_created_by');
0 ignored issues
show
Bug introduced by
The method dropForeign() does not seem to exist on object<LaraCed\LaraCedServiceProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
75
            $this->dropForeign('fk_' . $tableName . '_has_updated_by');
0 ignored issues
show
Bug introduced by
The method dropForeign() does not seem to exist on object<LaraCed\LaraCedServiceProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
76
            $this->dropForeign('fk_' . $tableName . '_has_deleted_by');
0 ignored issues
show
Bug introduced by
The method dropForeign() does not seem to exist on object<LaraCed\LaraCedServiceProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
77
        });
78
    }
79
}
80