Passed
Branch dev5a (b4693d)
by Ron
27:36
created

GetUserDetails   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
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 29
ccs 13
cts 13
cp 1
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getUserData() 0 6 1
A checkForDuplicate() 0 3 1
A __construct() 0 3 2
A getUserSettings() 0 6 1
1
<?php
2
3
namespace App\Domains\User;
4
5
use Illuminate\Support\Facades\Auth;
6
use Illuminate\Support\Facades\Log;
7
8
use App\User;
9
use App\UserSettings;
10
11
class GetUserDetails
12
{
13
    protected $userID;
14
15 8
    public function __construct($userID = null)
16
    {
17 8
        $this->userID = $userID ? $userID : Auth::user()->user_id;
18 8
    }
19
20 4
    public function getUserData()
21
    {
22 4
        $userData = User::find($this->userID)->makeVisible('username');
23 4
        Log::debug('User Data gathered for User ID '.$this->userID.'.  Gathered Data - ', $userData->toArray());
24
25 4
        return $userData;
26
    }
27
28 4
    public function getUserSettings()
29
    {
30 4
        $userSett = UserSettings::where('user_id', $this->userID)->first();
31 4
        Log::debug('User Settings gathered for User ID '.$this->userID.'.  Gathered Data - ', $userSett->toArray());
32
33 4
        return $userSett;
34
    }
35
36
    //  Determine if a username or email address is already in use
37 2
    public function checkForDuplicate($type, $value)
38
    {
39 2
        return User::where($type, $value)->first();
40
    }
41
}
42