Completed
Push — master ( 874c42...3f0650 )
by Ryan
02:09
created

GetCompleteResetPath   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 1
dl 36
loc 36
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A handle() 9 9 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 namespace Anomaly\UsersModule\User\Command;
2
3
use Anomaly\SettingsModule\Setting\Contract\SettingRepositoryInterface;
4
use Anomaly\UsersModule\User\Contract\UserInterface;
5
use Illuminate\Contracts\Bus\SelfHandling;
6
use Illuminate\Contracts\Encryption\Encrypter;
7
8
/**
9
 * Class GetCompleteResetPath
10
 *
11
 * @link          http://anomaly.is/streams-platform
12
 * @author        AnomalyLabs, Inc. <[email protected]>
13
 * @author        Ryan Thompson <[email protected]>
14
 * @package       Anomaly\UsersModule\User\Command
15
 */
16 View Code Duplication
class GetCompleteResetPath implements SelfHandling
0 ignored issues
show
Duplication introduced by
This class 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...
17
{
18
19
    /**
20
     * The user instance.
21
     *
22
     * @var UserInterface
23
     */
24
    protected $user;
25
26
    /**
27
     * Create a new GetCompleteResetPath instance.
28
     *
29
     * @param UserInterface $user
30
     */
31
    public function __construct(UserInterface $user)
32
    {
33
        $this->user = $user;
34
    }
35
36
    /**
37
     * Handle the command.
38
     *
39
     * @param SettingRepositoryInterface $settings
40
     * @return string|null
41
     */
42
    public function handle(SettingRepositoryInterface $settings, Encrypter $encrypter)
43
    {
44
        $email = $encrypter->encrypt($this->user->getEmail());
45
        $code  = $encrypter->encrypt($this->user->getResetCode());
46
47
        $query = "?email={$email}&code={$code}";
48
49
        return $settings->value('anomaly.module.users::complete_reset_path', 'reset/complete') . $query;
50
    }
51
}
52