ExcelRenderer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 4
Bugs 1 Features 0
Metric Value
eloc 7
dl 0
loc 49
rs 10
c 4
b 1
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 3 1
A exporter() 0 3 1
A render() 0 3 1
A setExcelExport() 0 5 1
1
<?php
2
3
namespace Sfneal\ViewExport\Excel\Utils;
4
5
use Sfneal\ViewExport\Excel\Exports\ViewExcelExport;
6
use Sfneal\ViewExport\Support\Adapters\Exporter;
7
use Sfneal\ViewExport\Support\Adapters\Renderer;
8
9
class ExcelRenderer extends Renderer
10
{
11
    /**
12
     * @var string
13
     */
14
    private $excelExportClass = ViewExcelExport::class;
15
16
    /**
17
     * Set the `ExcelExport` class to be used to render the Excel file.
18
     *
19
     * @param string $exportClass
20
     * @return $this
21
     */
22
    public function setExcelExport(string $exportClass): self
23
    {
24
        $this->excelExportClass = $exportClass;
25
26
        return $this;
27
    }
28
29
    /**
30
     * Render the content to a exportable object.
31
     *
32
     * @return object
33
     */
34
    protected function render(): object
35
    {
36
        return new $this->excelExportClass($this->content);
37
    }
38
39
    /**
40
     * Retrieve in an Exporter instance created from the $exportable.
41
     *
42
     * @param $exportable
43
     * @return ExcelExporter
44
     */
45
    protected function exporter($exportable): ExcelExporter
46
    {
47
        return new ExcelExporter($exportable);
48
    }
49
50
    /**
51
     * Load renderable content to an Exporter instance and render the output.
52
     *
53
     * @return Exporter|ExcelExporter
54
     */
55
    public function handle(): ExcelExporter
56
    {
57
        return parent::handle();
58
    }
59
}
60