CustomExport   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 11
c 1
b 0
f 0
dl 0
loc 31
ccs 14
cts 14
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A name() 0 3 1
A diskName() 0 3 1
A queueName() 0 3 1
A registerEvents() 0 7 2
A key() 0 3 1
1
<?php
2
3
namespace NovaResourceDynamicExport\Export;
4
5
use Laravel\Nova\Nova;
6
use Maatwebsite\Excel\Concerns\Exportable;
7
use Maatwebsite\Excel\Concerns\WithEvents;
8
use Maatwebsite\Excel\Events\AfterSheet;
9
10
/**
11
 * Export class, allow developer to extend configuration
12
 * and use it in nova admin as action to call.
13
 */
14
abstract class CustomExport implements WithEvents
15
{
16
    use Exportable, HasFileModel, WithNotification;
0 ignored issues
show
introduced by
The trait NovaResourceDynamicExport\Export\WithNotification requires some properties which are not provided by NovaResourceDynamicExport\Export\CustomExport: $name, $download_link, $exists
Loading history...
introduced by
The trait Maatwebsite\Excel\Concerns\Exportable requires some properties which are not provided by NovaResourceDynamicExport\Export\CustomExport: $disk, $diskOptions, $fileName, $filePath, $writerType, $headers
Loading history...
17
18 3
    public static function key(): string
19
    {
20 3
        return class_basename(static::class);
21
    }
22
23 3
    public static function name(): string
24
    {
25 3
        return Nova::humanize(class_basename(static::class));
26
    }
27
28 1
    public static function queueName(): ?string
29
    {
30 1
        return config('nova-resource-dynamic-export.defaults.queue');
31
    }
32
33 1
    public static function diskName(): ?string
34
    {
35 1
        return config('nova-resource-dynamic-export.defaults.disk');
36
    }
37
38 1
    public function registerEvents(): array
39
    {
40 1
        return [
41 1
            AfterSheet::class => function (AfterSheet $event) {
0 ignored issues
show
Unused Code introduced by
The parameter $event 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
            AfterSheet::class => function (/** @scrutinizer ignore-unused */ AfterSheet $event) {

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 1
                $fileModel = $this->saveFileFromModel();
43 1
                if($fileModel?->exists) {
44 1
                    $this->notifyUser($fileModel);
45
                }
46 1
            },
47 1
        ];
48
    }
49
}
50