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

GetUserStats::getUserTipFavs()   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\Log;
6
7
use Carbon\Carbon;
8
9
use App\FileLInks;
10
use App\TechTipFavs;
11
use App\CustomerFavs;
12
13
class GetUserStats
14
{
15
    protected $userID;
16
17 10
    public function __construct($userID)
18
    {
19 10
        $this->userID = $userID;
20 10
    }
21
22
    //  Get all Customer Favorites assigned to the user
23 4
    public function getUserCustomerFavs()
24
    {
25 4
        $favs = CustomerFavs::where('user_id', $this->userID)->get();
26 4
        Log::debug('Customer Favorites for User ID '.$this->userID.' gathered.  Data - ', $favs->toArray());
27
28 4
        return $favs->makeHidden('Customers');
29
    }
30
31
    //  Get all Tech Tip Favorites assigned to the user
32 4
    public function getUserTipFavs()
33
    {
34 4
        $favs = TechTipFavs::where('user_id', $this->userID)->get();
35 4
        Log::debug('Tech Tip Favorites for User ID '.$this->userID.' gathered.  Data - ', $favs->toArray());
36
37 4
        return $favs->makeHidden('TechTips');
38
    }
39
40
    //  Get a count of acctive file links the user has
41 4
    public function getUserActiveLinks()
42
    {
43 4
        $activeLinks = FileLinks::where('user_id', $this->userID)->where('expire', '>', Carbon::now())->count();
44 4
        Log::debug('Retrieved count of active File Links for User ID'.$this->userID.'. Data - ', ['Active Links' => $activeLinks]);
45
46 4
        return $activeLinks;
47
    }
48
49
    //  Get the total count of file links the user has
50 4
    public function getUserTotalLinks()
51
    {
52 4
        $totalLinks  = FileLinks::where('user_id', $this->userID)->count();
53 4
        Log::debug('Retrieved count of total File Links for User ID'.$this->userID.'. Data - ', ['Total Links' => $totalLinks]);
54
55 4
        return $totalLinks;
56
    }
57
}
58