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

ExportData   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A postExportData() 0 16 3
A getExportData() 0 3 1
1
<?php
2
3
namespace crocodicstudio\crudbooster\controllers\CBController;
4
5
use crocodicstudio\crudbooster\controllers\Helpers\IndexExport;
6
7
trait ExportData
8
{
9
    public function postExportData()
10
    {
11
        $this->limit = request('limit');
0 ignored issues
show
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

11
        $this->limit = /** @scrutinizer ignore-call */ request('limit');
Loading history...
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...
12
        $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...
13
        $filename = request('filename');
14
        $papersize = request('page_size');
15
        $paperorientation = request('page_orientation');
16
        $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

16
        /** @scrutinizer ignore-call */ 
17
        $indexContent = $this->getIndex();
Loading history...
17
18
        if (request('default_paper_size')) {
19
            $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

19
            $this->/** @scrutinizer ignore-call */ 
20
                   table('cms_settings')->where('name', 'default_paper_size')->update(['content' => $papersize]);
Loading history...
20
        }
21
        $format = request('fileformat');
22
        if(in_array($format, ['pdf', 'xls', 'csv']))
23
        {
24
            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

24
            return /** @scrutinizer ignore-call */ app(IndexExport::class)->{$format}($filename, $indexContent, $paperorientation, $papersize);
Loading history...
25
        }
26
    }
27
28
    public function getExportData()
29
    {
30
        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

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