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

GetUserDetails::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 1
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 2
rs 10
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