Passed
Push — dev5 ( 9ca56e...5adb95 )
by Ron
08:24
created

GetFileLinkFiles   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 95%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
c 1
b 0
f 0
dl 0
loc 34
ccs 19
cts 20
cp 0.95
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 16 2
A getGuestFiles() 0 12 1
1
<?php
2
3
namespace App\Domains\FileLinks;
4
5
use Illuminate\Support\Facades\Log;
6
7
use App\FileLinkFiles;
8
9
use App\Http\Resources\FileLinkFilesCollection;
10
11
class GetFileLinkFiles
12
{
13
    //  Execute will process an uploading file
14 2
    public function execute($linkID, $collection = false)
15
    {
16 2
        $files = FileLinkFiles::where('link_id', $linkID)
17 2
                    ->orderBy('user_id', 'ASC')
18 2
                    ->orderBy('created_at', 'ASC')
19 2
                    ->with('Files')
20 2
                    ->with('User')
21 2
                    ->get();
22
23 2
        Log::debug('Retrieved files attached to File Link ID '.$linkID.'.  Data Gathered - ', array($files));
24 2
        if($collection)
25
        {
26 2
            return new FileLinkFilesCollection($files);
27
        }
28
29
        return $files;
30
    }
31
32
    //  Only retrieve the files that the guest can download
33 6
    public function getGuestFiles($linkID)
34
    {
35 6
        $files = new FileLinkFilesCollection(
36 6
            FileLinkFiles::where('link_id', $linkID)
37 6
                ->where('upload', 0)
38 6
                ->orderBy('created_at', 'ASC')
39 6
                ->with('Files')
40 6
                ->get()
41
        );
42
43 6
        Log::debug('Retrieved guest files attached to File Link ID '.$linkID.'.  Data Gathered - ', array($files));
44 6
        return $files;
45
    }
46
}
47