ExportGedCom   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 3
eloc 19
c 2
b 0
f 1
dl 0
loc 44
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 22 2
A __construct() 0 4 1
1
<?php
2
3
namespace App\Jobs;
4
5
use Auth;
6
use File;
7
use Illuminate\Bus\Queueable;
8
use Illuminate\Contracts\Queue\ShouldQueue;
9
use Illuminate\Foundation\Bus\Dispatchable;
10
use Illuminate\Http\Request;
11
use Illuminate\Queue\InteractsWithQueue;
12
use Illuminate\Queue\SerializesModels;
13
use ModularSoftware\LaravelGedcom\Utils\GedcomGenerator;
14
15
class ExportGedCom implements ShouldQueue
16
{
17
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
0 ignored issues
show
introduced by
The trait Illuminate\Queue\SerializesModels requires some properties which are not provided by App\Jobs\ExportGedCom: $id, $relations, $class, $keyBy
Loading history...
18
19
    protected $family_id;
20
21
    /**
22
     * Create a new job instance.
23
     *
24
     * @return void
25
     */
26
    public function __construct($family_id, Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request 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

26
    public function __construct($family_id, /** @scrutinizer ignore-unused */ Request $request)

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...
27
    {
28
        //
29
        $this->family_id = $family_id;
30
    }
31
32
    /**
33
     * Execute the job.
34
     *
35
     * @return void
36
     */
37
    public function handle()
38
    {
39
        //
40
        $headers = [
0 ignored issues
show
Unused Code introduced by
The assignment to $headers is dead and can be removed.
Loading history...
41
            'Content-type' => 'text/txt',
42
        ];
43
        $p_id = 0;
44
        $f_id = $this->family_id;
45
        $up_nest = 3;
46
        $down_nest = 3;
47
        $writer = new GedcomGenerator($p_id, $f_id, $up_nest, $down_nest);
48
        $content = $writer->getGedcomPerson();
49
        // $user_id = Auth::user()->id;
50
        $ts = microtime(true);
51
        $file = env('APP_NAME').date('_Ymd_').$ts.'.GED';
52
        $destinationPath = public_path().'/upload/';
53
        if (! is_dir($destinationPath)) {
54
            mkdir($destinationPath, 0777, true);
55
        }
56
        File::put($destinationPath.$file, $content);
57
58
        return 0;
0 ignored issues
show
Bug Best Practice introduced by
The expression return 0 returns the type integer which is incompatible with the documented return type void.
Loading history...
59
    }
60
}
61