SentinelInstaller   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 98
Duplicated Lines 16.33 %

Coupling/Cohesion

Components 2
Dependencies 5
Metric Value
wmc 11
lcom 2
cbo 5
dl 16
loc 98
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A checkIsInstalled() 0 4 1
A composer() 0 10 1
A getHashedPassword() 0 4 1
A changeDefaultUserProvider() 0 7 1
A migrate() 0 8 2
A configure() 0 11 1
A seed() 8 8 2
A publish() 8 8 2

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 namespace Modules\Core\Console\Installers\Scripts\UserProviders;
2
3
use Modules\Core\Console\Installers\SetupScript;
4
5
class SentinelInstaller extends ProviderInstaller implements SetupScript
6
{
7
    /**
8
     * Check if the user driver is correctly registered.
9
     * @return bool
10
     */
11
    public function checkIsInstalled()
12
    {
13
        return class_exists('Cartalyst\Sentinel\Laravel\SentinelServiceProvider');
14
    }
15
16
    /**
17
     * Not called
18
     * @return mixed
19
     */
20
    public function composer()
21
    {
22
        $this->composer->enableOutput($this->command);
23
        $this->composer->install('cartalyst/sentinel:dev-feature/laravel-5');
24
        $this->composer->remove('cartalyst/sentry');
25
        $this->composer->dumpAutoload();
26
27
        // Dynamically register the service provider, so we can use it during publishing
28
        $this->application->register('Cartalyst\Sentinel\Laravel\SentinelServiceProvider');
29
    }
30
31
    /**
32
     * @return mixed
33
     */
34 View Code Duplication
    public function publish()
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...
35
    {
36
        if ($this->command->option('verbose')) {
37
            return $this->command->call('vendor:publish', ['--provider' => 'Cartalyst\Sentinel\Laravel\SentinelServiceProvider']);
38
        }
39
40
        return $this->command->callSilent('vendor:publish', ['--provider' => 'Cartalyst\Sentinel\Laravel\SentinelServiceProvider']);
41
    }
42
43
    /**
44
     * @return mixed
45
     */
46
    public function migrate()
47
    {
48
        if ($this->command->option('verbose')) {
49
            return $this->command->call('migrate');
50
        }
51
52
        return $this->command->callSilent('migrate');
53
    }
54
55
    /**
56
     * @return mixed
57
     */
58
    public function configure()
59
    {
60
        $this->replaceCartalystUserModelConfiguration(
61
            'Cartalyst\Sentinel\Users\EloquentUser',
62
            'Sentinel'
63
        );
64
65
        $this->changeDefaultUserProvider('Sentinel');
66
67
        $this->bindUserRepositoryOnTheFly('Sentinel');
68
    }
69
70
    /**
71
     * @return mixed
72
     */
73 View Code Duplication
    public function seed()
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 ($this->command->option('verbose')) {
76
            return $this->command->call('db:seed', ['--class' => 'Modules\User\Database\Seeders\SentinelGroupSeedTableSeeder']);
77
        }
78
79
        return $this->command->callSilent('db:seed', ['--class' => 'Modules\User\Database\Seeders\SentinelGroupSeedTableSeeder']);
80
    }
81
82
    /**
83
     * @param $password
84
     * @return mixed
85
     */
86
    public function getHashedPassword($password)
87
    {
88
        return $password;
89
    }
90
91
    /**
92
     * @param $driver
93
     * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
94
     */
95
    private function changeDefaultUserProvider($driver)
96
    {
97
        $path = base_path('config/asgard.user.users.php');
98
        $config = $this->finder->get($path);
99
        $config = str_replace('Sentry', $driver, $config);
100
        $this->finder->put($path, $config);
101
    }
102
}
103