Passed
Push — master ( 630dec...39e786 )
by Curtis
10:08
created

Store::__invoke()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 14
rs 10
c 0
b 0
f 0
cc 3
nc 3
nop 1
1
<?php
2
3
namespace App\Http\Controllers\Gedcom;
4
5
use App\Note;
6
use App\Event;
7
use App\Family;
8
use App\Person;
9
use App\Source;
10
use Illuminate\Http\Request;
11
use App\Http\Controllers\Controller;
12
use Asdfx\LaravelGedcom\Facades\GedcomParserFacade;
13
14
class Store extends Controller
15
{
16
    /*
17
    * Api end-point for Gedcom api/gedcom/store
18
    * Saving uploaded file to storage and starting to read
19
    */
20
21
    public function __invoke(Request $request)
22
    {
23
        if ($request->hasFile('file')) {
24
            if ($request->file('file')->isValid()) {
25
                $request->file->storeAs('gedcom', 'file.ged');
26
                $this->readData($request->file);
27
28
                return ['File uploaded'];
29
            }
30
31
            return ['File corrupted'];
32
        }
33
34
        return ['Not uploaded'];
35
    }
36
37
    /*
38
    * Read ged file
39
    */
40
41
    public function readData($filename)
0 ignored issues
show
Unused Code introduced by
The parameter $filename is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

41
    public function readData(/** @scrutinizer ignore-unused */ $filename)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
42
    {
43
	$filename = $this->filename;
0 ignored issues
show
Bug Best Practice introduced by
The property filename does not exist on App\Http\Controllers\Gedcom\Store. Did you maybe forget to declare it?
Loading history...
44
	GedcomParserFacade::parse($filename, true);
45
    }
46
47
}
48