Passed
Pull Request — master (#1093)
by Iman
06:16
created

ExportData::getExportData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace crocodicstudio\crudbooster\controllers\CBController;
4
5
use crocodicstudio\crudbooster\controllers\Helpers\IndexExport;
6
7
trait ExportData
8
{
9
    public $button_export = true;
10
11
    public function postExportData()
12
    {
13
        $this->limit = request('limit');
0 ignored issues
show
Bug Best Practice introduced by
The property limit does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
Bug introduced by
The function request was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

13
        $this->limit = /** @scrutinizer ignore-call */ request('limit');
Loading history...
14
        $this->index_return = true;
0 ignored issues
show
Bug Best Practice introduced by
The property index_return does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
15
        $filename = request('filename');
16
        $papersize = request('page_size');
17
        $paperorientation = request('page_orientation');
18
        $indexContent = $this->getIndex();
0 ignored issues
show
Bug introduced by
It seems like getIndex() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

18
        /** @scrutinizer ignore-call */ 
19
        $indexContent = $this->getIndex();
Loading history...
19
20
        if (request('default_paper_size')) {
21
            $this->table('cms_settings')->where('name', 'default_paper_size')->update(['content' => $papersize]);
0 ignored issues
show
Bug introduced by
It seems like table() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

21
            $this->/** @scrutinizer ignore-call */ 
22
                   table('cms_settings')->where('name', 'default_paper_size')->update(['content' => $papersize]);
Loading history...
22
        }
23
        $format = request('fileformat');
24
        if(in_array($format, ['pdf', 'xls', 'csv']))
25
        {
26
            return app(IndexExport::class)->{$format}($filename, $indexContent, $paperorientation, $papersize);
0 ignored issues
show
Bug introduced by
The function app was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

26
            return /** @scrutinizer ignore-call */ app(IndexExport::class)->{$format}($filename, $indexContent, $paperorientation, $papersize);
Loading history...
27
        }
28
    }
29
30
    public function getExportData()
31
    {
32
        return redirect(CB::mainpath());
0 ignored issues
show
Bug introduced by
The function redirect was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

32
        return /** @scrutinizer ignore-call */ redirect(CB::mainpath());
Loading history...
33
    }
34
35
}