JpasImport::getFile()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 0
cts 11
cp 0
rs 9.7666
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 6
1
<?php
2
3
namespace SET\Handlers\Excel;
4
5
use Illuminate\Support\Facades\File;
6
use Illuminate\Support\Facades\Input;
7
use Illuminate\Support\Facades\Storage;
8
use Maatwebsite\Excel\Files\ExcelFile;
9
10
class JpasImport extends ExcelFile
11
{
12
    public function getFile()
13
    {
14
        //If we pass a filepath, use it and get out
15
        if (Input::has('uploadedFile')) {
16
            return Input::get('uploadedFile');
17
        }
18
        //Process the excel file provided.
19
        $file = Input::file('file');
20
        $fileName = $file->getClientOriginalName();
21
        Storage::disk('local')->put($fileName, File::get($file));
22
23
        $storagePath = Storage::disk('local')->getDriver()->getAdapter()->getPathPrefix();
24
25
        return $storagePath.$fileName;
26
    }
27
28
    public function getFilters()
29
    {
30
        return [
31
            'chunk',
32
        ];
33
    }
34
}
35