Completed
Push — master ( f40498...e3ae3a )
by ARCANEDEV
03:17
created

UserValidator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 0
cbo 1
dl 0
loc 27
ccs 0
cts 8
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A validateUserPassword() 0 10 2
1
<?php namespace Arcanesoft\Auth\Validators;
2
3
use Illuminate\Support\Facades\Hash;
4
5
/**
6
 * Class     UserValidator
7
 *
8
 * @package  Arcanesoft\Auth\Validators
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class UserValidator
12
{
13
    /* ------------------------------------------------------------------------------------------------
14
     |  Validation Functions
15
     | ------------------------------------------------------------------------------------------------
16
     */
17
    /**
18
     * Validate the user current/old password.
19
     *
20
     * @param  string                            $attribute
21
     * @param  string                            $value
22
     * @param  array                             $parameters
23
     * @param  \Illuminate\Validation\Validator  $validator
24
     *
25
     * @return bool
26
     */
27
    public function validateUserPassword($attribute, $value, $parameters, $validator)
28
    {
29
        unset($attribute, $parameters, $validator);
30
31
        if (auth()->guest()) {
32
            return false;
33
        }
34
35
        return Hash::check($value, auth()->user()->password);
0 ignored issues
show
Bug introduced by
Accessing password on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
36
    }
37
}
38