DisplayResultsStep   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 26
dl 0
loc 55
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A process() 0 2 1
A rules() 0 3 1
A validate() 0 2 1
A fields() 0 7 1
A preProcess() 0 21 3
1
<?php
2
3
/** Created by PhpStorm,  User: jonphipps,  Date: 2017-05-31,  Time: 11:14 AM */
4
5
namespace App\Wizard\Import\ProjectSteps;
6
7
use App\Models\Import;
8
use Illuminate\Http\Request;
9
use Smajti1\Laravel\Step;
10
use Smajti1\Laravel\Wizard;
11
12
class DisplayResultsStep extends Step
13
{
14
    public static $label = 'Here are your results...';
15
    public static $slug  = 'results';
16
    public static $view  = 'frontend.import.project.steps.results';
17
18
    public function fields(): array
19
    {
20
        return [
21
            [
22
                'name'  => 'results',
23
                'label' => '',
24
                'type'  => 'jqxgrid_select',
25
            ],
26
        ];
27
    }
28
29
    public function preProcess(Request $request, Wizard $wizard)
30
    {
31
        /** @var Import[] $imports */
32
        $imports = $request->batch->imports;
33
        $data    = [];
34
        foreach ($imports as $import) {
35
            $results['results']   = $import->results['timer'][0];
36
            $results['worksheet'] = $import->source_file_name;
37
            $results['processed'] = $import->total_processed_count;
38
            $results['updated']   = $import->updated_count;
39
            $results['added']     = $import->added_count;
40
            $results['deleted']   = $import->deleted_count;
41
            $results['errors']    = $import->error_count;
42
            $results['import_id'] = $import->id;
43
            $path                 = $import->schema_id ? 'schemaimports' : 'imports';
44
            $results['history']   = "<a href=\"/{$path}/{$import->id}/history\">{$import->id}</a>";
45
            $data[]               = $results;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $results seems to be defined later in this foreach loop on line 35. Are you sure it is defined here?
Loading history...
46
        }
47
        $wizardData            = $wizard->data();
48
        $wizardData['results'] = $data;
49
        $wizard->data($wizardData);
50
    }
51
52
    public function process(Request $request): void
53
    {
54
        // This will be a generic report of all of the imports in this run
55
        // it should maybe be a normal report screen rather than a step
56
        // there should be  andOK/Finish button
57
        //$this->saveProgress($request);
58
    }
59
60
    public function validate(Request $request): void
61
    {
62
    }
63
64
    public function rules(Request $request = null): array
65
    {
66
        return [];
67
    }
68
}
69