Passed
Push — dev5a ( d46f4b...f24c41 )
by Ron
07:14
created

PasswordPolicy   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A setPolicy() 0 21 2
1
<?php
2
3
namespace App\Domains\Admin;
4
5
use App\User;
6
use Carbon\Carbon;
7
8
class PasswordPolicy extends SettingsDomain
9
{
10 6
    public function setPolicy($request)
11
    {
12
        //  Update the main policy
13 6
        $this->updateSettings('auth.passwords.settings.expire', $request->expire);
14
15
        //  Update all users to reflect the new policy
16 6
        if($request->expire == 0)
17
        {
18 2
            User::where('password_expires', '>', NOW())->update([
19 2
                'password_expires' => null,
20
            ]);
21
        }
22
        else
23
        {
24 4
            $newExpire = Carbon::now()->addDays($request->expire);
25 4
            User::whereNull('password_expires')->update([
26 4
                'password_expires' => $newExpire,
27
            ]);
28
        }
29
30 6
        return true;
31
    }
32
}
33