Completed
Push — master ( 5dab40...ca534d )
by Maxime
120:18 queued 114:35
created

ExcelExporter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 0
dl 0
loc 42
ccs 0
cts 28
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B export() 0 38 2
1
<?php
2
/**
3
     * Created by PhpStorm.
4
     * User: mfrancois
5
     * Date: 6/02/2015
6
     * Time: 4:37 PM
7
     */
8
9
namespace Distilleries\Expendable\Exporter;
10
11
use Distilleries\Expendable\Contracts\ExcelExporterContract;
12
13
class ExcelExporter implements ExcelExporterContract {
14
15
16
    public function export($data, $filename = '')
17
    {
18
19
20
        $excel = \Excel::create($filename, function($excel) use ($data)
21
        {
22
23
            $excel->sheet('export', function($sheet) use ($data)
24
            {
25
26
                $sheet->fromArray($data);
27
                $sheet->freezeFirstRow();
28
                $sheet->setAutoFilter();
29
                $sheet->row(1, function($row)
30
                {
31
                    $row->setValignment('middle');
32
                    $row->setAlignment('center');
33
                    $row->setFontColor('#ffffff');
34
                    $row->setFont(array(
35
                        'size' => '12',
36
                        'bold' => true
37
                    ));
38
                    $row->setBackground('#000000');
39
40
                });
41
42
            });
43
44
45
        });
46
47
        if (app()->environment('testing'))
48
        {
49
            $excel->store('xls');
50
        }
51
52
        $excel->export('xls')->download('xls');
53
    }
54
}