Passed
Push — master ( d63a45...8016ac )
by Iman
09:10
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 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->indexReturn = true;
0 ignored issues
show
Bug Best Practice introduced by
The property indexReturn 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);
25
        }
26
    }
27
28
    public function getExportData()
29
    {
30
        return redirect(CRUDBooster::mainpath());
0 ignored issues
show
Bug introduced by
The type Crocodicstudio\Crudboost...BController\CRUDBooster 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...
31
    }
32
33
}