EloquentUserProviderWithPasswordUpdate   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 18
ccs 9
cts 9
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A updatePassword() 0 11 1
A __construct() 0 3 1
1
<?php
2
3
namespace SamAsEnd\NeedsAutoRehash\Providers;
4
5
use Illuminate\Auth\EloquentUserProvider;
6
use Illuminate\Contracts\Auth\Authenticatable;
7
8
class EloquentUserProviderWithPasswordUpdate extends EloquentUserProvider implements ProviderWithPasswordUpdate
9
{
10 2
    public function __construct(EloquentUserProvider $provider)
11
    {
12 2
        parent::__construct($provider->hasher, $provider->model);
13 2
    }
14
15 2
    public function updatePassword(Authenticatable $user, $plainPassword)
16
    {
17 2
        $user->password = $this->hasher->make($plainPassword);
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?
Loading history...
18
19 2
        $timestamps = $user->timestamps;
0 ignored issues
show
Bug introduced by
Accessing timestamps on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
20
21 2
        $user->timestamps = false;
22
23 2
        $user->save();
24
25 2
        $user->timestamps = $timestamps;
26 2
    }
27
}
28