Completed
Push — master ( 56bd52...cf94f2 )
by ARCANEDEV
8s
created

ExporterManager::buildExporter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 1
1
<?php namespace Arcanedev\LaravelExcel;
2
3
use Arcanedev\LaravelExcel\Contracts\ExporterManager as ExporterManagerContract;
4
5
/**
6
 * Class     ExporterManager
7
 *
8
 * @package  Arcanedev\LaravelExcel
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class ExporterManager extends AbstractManager implements ExporterManagerContract
12
{
13
    /* -----------------------------------------------------------------
14
     |  Main Drivers
15
     | -----------------------------------------------------------------
16
     */
17
18
    /**
19
     * Get a exporter instance.
20
     *
21
     * @param  string  $driver
22
     *
23
     * @return \Arcanedev\LaravelExcel\Contracts\Exporter
24
     */
25 9
    public function make($driver)
26
    {
27 9
        return $this->driver($driver);
28
    }
29
30
    /**
31
     * Get the Excel driver instance.
32
     *
33
     * @return \Arcanedev\LaravelExcel\Contracts\Exporter
34
     */
35 3
    public function createExcelDriver()
36
    {
37 3
        return $this->buildExporter('excel');
38
    }
39
40
    /**
41
     * Get the CSV driver instance.
42
     *
43
     * @return \Arcanedev\LaravelExcel\Contracts\Exporter
44
     */
45 3
    public function createCsvDriver()
46
    {
47 3
        return $this->buildExporter('csv');
48
    }
49
50
    /**
51
     * Get the Open office driver instance.
52
     *
53
     * @return \Arcanedev\LaravelExcel\Contracts\Exporter
54
     */
55 3
    public function createOpenOfficeDriver()
56
    {
57 3
        return $this->buildExporter('ods');
58
    }
59
60
    /* -----------------------------------------------------------------
61
     |  Other Methods
62
     | -----------------------------------------------------------------
63
     */
64
65
    /**
66
     * Build the exporter.
67
     *
68
     * @param  string  $driver
69
     *
70
     * @return \Arcanedev\LaravelExcel\Contracts\Exporter
71
     */
72 9
    protected function buildExporter($driver)
73
    {
74 9
        return $this->app->makeWith(
75 9
            $this->getDriverExporter($driver),
76 9
            $this->getDriverOptions($driver)
77
        );
78
    }
79
}
80