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

GetUserDetails::getUserSettings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

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