StudentImport::sheets()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Imports;
4
5
use App\Institution_student;
0 ignored issues
show
Bug introduced by
The type App\Institution_student 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...
6
use Maatwebsite\Excel\Concerns\WithEvents;
7
use Maatwebsite\Excel\Concerns\ToModel;
8
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
9
use Maatwebsite\Excel\Events\BeforeSheet;
10
11
class StudentImport implements WithMultipleSheets, WithEvents
12
{
13
14
    public function __construct()
15
    {
16
        $this->sheetNames = [];
0 ignored issues
show
Bug Best Practice introduced by
The property sheetNames does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
17
        $this->sheetData = [];
0 ignored issues
show
Bug Best Practice introduced by
The property sheetData does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
18
    }
19
20
    /**
21
    * @param array $row
22
    *
23
    * @return \Illuminate\Database\Eloquent\Model|null
24
    */
25
26
    public function sheets(): array
27
    {
28
        return [
0 ignored issues
show
Bug Best Practice introduced by
The expression return array(0 => $this) returns the type array<integer,App\Imports\StudentImport> which is incompatible with the documented return type Illuminate\Database\Eloquent\Model|null.
Loading history...
29
30
            0 => $this
31
        ];
32
    }
33
34
    public function array(array $array){
35
        $this->sheetData[] = $array;
0 ignored issues
show
Bug Best Practice introduced by
The property sheetData does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
36
    }
37
38
    public function registerEvents(): array
39
    {
40
        // TODO: Implement registerEvents() method.
41
42
        return [
43
            BeforeSheet::class => function(BeforeSheet $event){
44
                $this->sheetNames[] = $event->getSheet()->getTitle();
0 ignored issues
show
Bug Best Practice introduced by
The property sheetNames does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
45
46
            }
47
        ];
48
49
    }
50
51
}
52