Passed
Push — dev5a ( e86993...328ab1 )
by Ron
10:15 queued 39s
created

GetFiles   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 24
ccs 0
cts 10
cp 0
rs 10
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A canUserDownload() 0 10 3
A validateFile() 0 10 3
1
<?php
2
3
namespace App\Domains\Files;
4
5
use App\Files;
6
use Illuminate\Support\Facades\Auth;
7
use Illuminate\Support\Facades\Log;
8
use Illuminate\Support\Facades\Storage;
9
10
class GetFiles
11
{
12
    public function validateFile($fileID, $fileName)
13
    {
14
        $fileData = Files::where('file_id', $fileID)->where('file_name', $fileName)->first();
15
16
        if(!$fileData || !Storage::exists($fileData->file_link.$fileData->file_name))
17
        {
18
            return false;
19
        }
20
21
        return $fileData->file_link.$fileData->file_name;
22
    }
23
24
    public function canUserDownload($fileID, $authorized)
25
    {
26
        $fileData = Files::find($fileID);
27
28
        if(!$authorized && !$fileData->public)
29
        {
30
            return false;
31
        }
32
33
        return true;
34
    }
35
}
36