Passed
Push — master ( 6a3267...5596bf )
by Curtis
12:56 queued 05:56
created

ExportGedCom   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 19 2
A __construct() 0 4 1
1
<?php
2
3
namespace App\Jobs;
4
5
use Illuminate\Bus\Queueable;
6
use Illuminate\Contracts\Queue\ShouldQueue;
7
use Illuminate\Foundation\Bus\Dispatchable;
8
use Illuminate\Queue\InteractsWithQueue;
9
use Illuminate\Queue\SerializesModels;
10
use Illuminate\Http\Request;
11
use ModularSoftware\LaravelGedcom\Utils\GedcomGenerator;
0 ignored issues
show
Bug introduced by
The type ModularSoftware\LaravelG...m\Utils\GedcomGenerator was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use File;
13
use Auth;
14
class ExportGedCom implements ShouldQueue
15
{
16
    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...
17
18
    protected $family_id;
19
    /**
20
     * Create a new job instance.
21
     *
22
     * @return void
23
     */
24
    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

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