Completed
Push — master ( 22c257...e714e6 )
by Gabriel
13:14 queued 10:09
created

XLS   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 35
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A output() 0 9 1
A initBasePath() 0 3 1
A instance() 0 7 2
1
<?php
2
3
namespace Nip\View;
4
5
use Nip\View;
6
7
/**
8
 * Class XLS
9
 * @package Nip\View
10
 */
11
class XLS extends View
12
{
13
14
    /**
15
     * Singleton
16
     *
17
     * @return self
18
     */
19
    public static function instance()
20
    {
21
        static $instance;
22
        if (!($instance instanceof self)) {
23
            $instance = new self();
24
        }
25
        return $instance;
26
    }
27
28
    public function initBasePath()
29
    {
30
        $this->setBasePath(MODULES_PATH . request()->getModuleName() . '/views/');
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

30
        $this->setBasePath(MODULES_PATH . /** @scrutinizer ignore-call */ request()->getModuleName() . '/views/');
Loading history...
Bug introduced by
The constant Nip\View\MODULES_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
31
    }
32
33
    /**
34
     * @param $view
35
     * @param $name
36
     */
37
    public function output($view, $name)
38
    {
39
        header("Content-type: application/vnd.ms-excel");
40
        header("Content-Disposition: attachment; filename=\"$name\"");
41
        header("Cache-Control: private, max-age=1, pre-check=1", true);
42
        header("Pragma: none", true);
43
44
        echo $this->load($view);
45
        exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
46
    }
47
}
48