Test Setup Failed
Push — master ( 72885b...568721 )
by Mohamed
02:18 queued 11s
created

ExaminationStudentsExport::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Exports;
4
5
use App\Models\Examination_student;
6
use Illuminate\Contracts\Queue\ShouldQueue;
7
use Maatwebsite\Excel\Concerns\FromQuery;
8
use Maatwebsite\Excel\Concerns\Exportable;
9
use Maatwebsite\Excel\Concerns\FromCollection;
10
use Maatwebsite\Excel\Concerns\WithHeadings;
11
use Carbon\Carbon;
12
13
class ExaminationStudentsExport implements FromQuery , WithHeadings 
14
{
15
16
    use Exportable;
0 ignored issues
show
introduced by
The trait Maatwebsite\Excel\Concerns\Exportable requires some properties which are not provided by App\Exports\ExaminationStudentsExport: $disk, $diskOptions, $fileName, $filePath, $writerType, $headers
Loading history...
17
18
    public function __construct($year,$grade)
19
    {
20
        $this->year = $year;
0 ignored issues
show
Bug Best Practice introduced by
The property year does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
21
        $this->grade = $grade;
0 ignored issues
show
Bug Best Practice introduced by
The property grade does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
22
    }
23
    
24
    public function headings(): array
25
    {
26
        return [
27
            'st_no',
28
            'stu_no',
29
            'nsid',
30
            'schoolid',
31
            'f_name',
32
            'medium',
33
            'b_date',
34
            'gender',
35
            'pvt_address',
36
            'a_income',
37
            'spl_need',
38
            'disability_type',
39
            'disability',
40
            'sp_center',
41
            'created_at',
42
            'updated_at'
43
        ];
44
    }
45
    
46
    /**
47
    * @return \Illuminate\Support\Collection
48
    */
49
    public function query()
50
    {
51
        return Examination_student::query()->whereNotNull('nsid')
0 ignored issues
show
Bug Best Practice introduced by
The expression return App\Models\Examin...('grade', $this->grade) also could return the type Illuminate\Database\Eloq...\Database\Query\Builder which is incompatible with the documented return type Illuminate\Support\Collection.
Loading history...
52
        ->distinct('nsid')
0 ignored issues
show
Unused Code introduced by
The call to Illuminate\Database\Query\Builder::distinct() has too many arguments starting with 'nsid'. ( Ignorable by Annotation )

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

52
        ->/** @scrutinizer ignore-call */ distinct('nsid')

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
53
        ->where('year',$this->year)
54
        ->where('grade',$this->grade);
55
    }
56
}
57