Completed
Push — master ( c86b4a...6e0f3c )
by Shawn
05:29
created

ResolveLdap   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 7 2
A activateUsers() 0 5 1
1
<?php
2
3
namespace SET\Listeners;
4
5
use Carbon\Carbon;
6
use Illuminate\Contracts\Queue\ShouldQueue;
7
use Illuminate\Support\Facades\Artisan;
8
use SET\User;
9
10
class ResolveLdap implements ShouldQueue
11
{
12
    /**
13
     * Build the event handler.
14
     */
15
    public function __construct()
16
    {
17
        //
18
    }
19
20
    /**
21
     * Call to add missing users.
22
     */
23
    public function handle()
24
    {
25
        if (config('auth.providers.users.driver') == 'adldap') {
26
            Artisan::call('adldap:import');
27
            $this->activateUsers();
28
        }
29
    }
30
31
    private function activateUsers()
32
    {
33
        User::whereBetween('created_at', [Carbon::now()->subMinutes(3), Carbon::now()])
34
        ->update(['status' => 'active']);
35
    }
36
}
37