Passed
Push — master ( adf913...831269 )
by Stephen
01:02 queued 11s
created

ExcelRenderer::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Sfneal\ViewExport\Excel\Utils;
4
5
use phpDocumentor\Reflection\Types\ClassString;
6
use Sfneal\ViewExport\Support\Exporter;
7
use Sfneal\ViewExport\Support\Renderer;
8
9
class ExcelRenderer extends Renderer
10
{
11
    /**
12
     * @var ClassString
13
     */
14
    private $excelViewClass = ExcelView::class;
15
16
    /**
17
     * Set the ExcelView class to be used to render the Excel file.
18
     *
19
     * @param ClassString $viewClass
20
     * @return $this
21
     */
22
    public function setExcelView(ClassString $viewClass): self
23
    {
24
        $this->excelViewClass = $viewClass;
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->excelViewClass($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