Passed
Push — dev5 ( 67c7cf...c7611f )
by Ron
19:22
created

GetFileLinks   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 22
ccs 12
cts 12
cp 1
rs 10
c 1
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 2
A execute() 0 12 2
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 6
    public function __construct($id, $collection = false)
17
    {
18 6
        $id == 0 ? $this->id = Auth::user()->user_id : $this->id = $id;
19 6
        $this->collection = $collection;
20 6
    }
21
22 6
    public function execute()
23
    {
24 6
        $links = FileLinks::where('user_id', $this->id)
25 6
                    ->withCount('FileLinkFiles')
26 6
                    ->orderBy('expire', 'desc')->get();
27
28 6
        Log::debug('Retrieved all File Links for User ID '.$this->id.'.  Data Gathered - ', array($links));
29 6
        if($this->collection) {
30 4
            return new FileLinksCollection($links);
31
        }
32
33 2
        return $links;
34
    }
35
}
36