Passed
Push — dev5 ( 8481ee...a622eb )
by Ron
03:52 queued 01:34
created

GetFileLinks::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 2
rs 10
1
<?php
2
3
namespace App\Domains\FileLinks;
4
5
use Illuminate\Support\Facades\Log;
6
use Illuminate\Support\Facades\Auth;
7
8
use App\FileLinks;
9
10
use App\Http\Resources\FileLinksCollection;
11
12
class GetFileLinks
13
{
14
    protected $id, $collection;
15
16 4
    public function __construct($id, $collection = false)
17
    {
18 4
        $id == 0 ? $this->id = Auth::user()->user_id : $this->id = $id;
19 4
        $this->collection = $collection;
20 4
    }
21
22 4
    public function execute()
23
    {
24 4
        $links = FileLinks::where('user_id', $this->id)
25 4
                    ->withCount('FileLinkFiles')
26 4
                    ->orderBy('expire', 'desc')->get();
27
28 4
        Log::debug('Retrieved all File Links for User ID '.$this->id.'.  Data Gathered - ', array($links));
29 4
        if($this->collection) {
30 4
            return new FileLinksCollection($links);
31
        }
32
33
        return $links;
34
    }
35
}
36