LaraCedServiceProvider::register()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 64

Duplication

Lines 15
Ratio 23.44 %

Importance

Changes 0
Metric Value
dl 15
loc 64
rs 8.7853
c 0
b 0
f 0
cc 1
nc 1
nop 0

How to fix   Long Method   

Long Method

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:

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