Completed
Push — master ( 67c7d1...f02869 )
by Nicolas
02:52
created

SentryInstaller   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 83
Duplicated Lines 19.28 %

Coupling/Cohesion

Components 3
Dependencies 3
Metric Value
wmc 10
lcom 3
cbo 3
dl 16
loc 83
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A checkIsInstalled() 0 4 1
A composer() 0 4 1
A getHashedPassword() 0 4 1
A publish() 8 8 2
A migrate() 0 8 2
A configure() 0 9 1
A seed() 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 SentryInstaller extends ProviderInstaller implements SetupScript
6
{
7
    /**
8
     * @var string
9
     */
10
    protected $driver = 'Sentry';
11
12
    /**
13
     * Check if the user driver is correctly registered.
14
     * @return bool
15
     */
16
    public function checkIsInstalled()
17
    {
18
        return class_exists('Cartalyst\Sentry\SentryServiceProvider');
19
    }
20
21
    /**
22
     * Not called
23
     * @return mixed
24
     */
25
    public function composer()
26
    {
27
        $this->application->register('Cartalyst\Sentry\SentryServiceProvider');
28
    }
29
30
    /**
31
     * @return mixed
32
     */
33 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...
34
    {
35
        if ($this->command->option('verbose')) {
36
            return $this->command->call('vendor:publish', ['--provider' => 'Cartalyst\Sentry\SentryServiceProvider']);
37
        }
38
39
        return $this->command->callSilent('vendor:publish', ['--provider' => 'Cartalyst\Sentry\SentryServiceProvider']);
40
    }
41
42
    /**
43
     * @return mixed
44
     */
45
    public function migrate()
46
    {
47
        if ($this->command->option('verbose')) {
48
            return $this->command->call('migrate');
49
        }
50
51
        return $this->command->callSilent('migrate');
52
    }
53
54
    /**
55
     * @return mixed
56
     */
57
    public function configure()
58
    {
59
        $this->replaceCartalystUserModelConfiguration(
60
            'Cartalyst\Sentry\Users\Eloquent\User',
61
            $this->driver
62
        );
63
64
        $this->bindUserRepositoryOnTheFly('Sentry');
65
    }
66
67
    /**
68
     * @return mixed
69
     */
70 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...
71
    {
72
        if ($this->command->option('verbose')) {
73
            return $this->command->call('db:seed', ['--class' => 'Modules\User\Database\Seeders\SentryGroupSeedTableSeeder']);
74
        }
75
76
        return $this->command->callSilent('db:seed', ['--class' => 'Modules\User\Database\Seeders\SentryGroupSeedTableSeeder']);
77
    }
78
79
    /**
80
     * @param $password
81
     * @return mixed
82
     */
83
    public function getHashedPassword($password)
84
    {
85
        return $password;
86
    }
87
}
88