AllowFormats   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 34
ccs 0
cts 12
cp 0
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A makeExportableUrl() 0 8 1
A scaffoldFormats() 0 5 2
A formats() 0 3 1
1
<?php
2
3
namespace Terranet\Administrator\Traits\Module;
4
5
use Illuminate\Support\Facades\Request;
6
7
trait AllowFormats
8
{
9
    /**
10
     * Available export formats.
11
     *
12
     * @return array
13
     */
14
    public function formats()
15
    {
16
        return $this->scaffoldFormats();
17
    }
18
19
    /**
20
     * Get exportable url.
21
     *
22
     * @param $format
23
     *
24
     * @return string
25
     */
26
    public function makeExportableUrl($format)
27
    {
28
        $payload = array_merge([
29
            'module' => $this->url(),
0 ignored issues
show
Bug introduced by
It seems like url() 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

29
            'module' => $this->/** @scrutinizer ignore-call */ url(),
Loading history...
30
            'format' => $format,
31
        ], Request::all());
32
33
        return route('scaffold.export', $payload);
0 ignored issues
show
Bug introduced by
The function route 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

33
        return /** @scrutinizer ignore-call */ route('scaffold.export', $payload);
Loading history...
34
    }
35
36
    protected function scaffoldFormats()
37
    {
38
        return property_exists($this, 'exportableTo')
39
            ? $this->exportableTo
40
            : config('administrator.export.'.$this->url(), config('administrator.export.default'));
0 ignored issues
show
Bug introduced by
The function config 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

40
            : /** @scrutinizer ignore-call */ config('administrator.export.'.$this->url(), config('administrator.export.default'));
Loading history...
41
    }
42
}
43