Test Failed
Push — dev5 ( ba6069...125e24 )
by Ron
09:51
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 11
cts 11
cp 1
rs 10
wmc 5

4 Methods

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