Code Duplication    Length = 22-22 lines in 2 locations

src/Validation/Rules/PasswordNotOld.php 1 location

@@ 9-30 (lines=22) @@
6
use Albert221\Validation\Rule\RuleTrait as RuleTrait;
7
use App\Models\User;
8
9
class PasswordNotOld implements RuleInterface
10
{
11
    use RuleTrait;
12
13
    public function __construct()
14
    {
15
        $this->message = 'Podane hasło jest nieprawidłowe';
16
    }
17
18
    public function test($value)
19
    {
20
        $user = User::find($_SESSION['user']);
21
        
22
        if (!$user) {
23
            return false;
24
        }
25
        
26
        if (!password_verify($value, $user->password)) {
27
            return true;
28
        }
29
30
        return false;
31
    }
32
}
33

src/Validation/Rules/PasswordOld.php 1 location

@@ 9-30 (lines=22) @@
6
use Albert221\Validation\Rule\RuleTrait as RuleTrait;
7
use App\Models\User;
8
9
class PasswordOld implements RuleInterface
10
{
11
    use RuleTrait;
12
13
    public function __construct()
14
    {
15
        $this->message = 'Podane hasło jest nieprawidłowe';
16
    }
17
18
    public function test($value)
19
    {
20
        $user = User::find($_SESSION['user']);
21
        
22
        if (!$user) {
23
            return false;
24
        }
25
        
26
        if (password_verify($value, $user->password)) {
27
            return true;
28
        }
29
30
        return false;
31
    }
32
}
33