Completed
Pull Request — master (#1)
by ARCANEDEV
07:05 queued 03:23
created

LaravelExcelServiceProvider::getBasePath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php namespace Arcanedev\LaravelExcel;
2
3
use Arcanedev\Support\PackageServiceProvider;
4
5
/**
6
 * Class     LaravelExcelServiceProvider
7
 *
8
 * @package  Arcanedev\LaravelExcel
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class LaravelExcelServiceProvider extends PackageServiceProvider
12
{
13
    /* ------------------------------------------------------------------------------------------------
14
     |  Properties
15
     | ------------------------------------------------------------------------------------------------
16
     */
17
    /**
18
     * Package name.
19
     *
20
     * @var string
21
     */
22
    protected $package = 'laravel-excel';
23
24
    /**
25
     * Indicates if loading of the provider is deferred.
26
     *
27
     * @var bool
28
     */
29
    protected $defer = true;
30
31
    /* ------------------------------------------------------------------------------------------------
32
     |  Getters & Setters
33
     | ------------------------------------------------------------------------------------------------
34
     */
35
    /**
36
     * Get the base path of the package.
37
     *
38
     * @return string
39
     */
40
    public function getBasePath()
41
    {
42
        return dirname(__DIR__);
43
    }
44
45
    /* ------------------------------------------------------------------------------------------------
46
     |  Main Functions
47
     | ------------------------------------------------------------------------------------------------
48
     */
49
    /**
50
     * Register the service provider.
51
     */
52
    public function register()
53
    {
54
        $this->registerConfig();
55
        $this->registerExporter();
56
        $this->registerImporter();
57
    }
58
59
    /**
60
     * Boot the service provider.
61
     */
62
    public function boot()
63
    {
64
        //
65
    }
66
67
    /**
68
     * Get the services provided by the provider.
69
     *
70
     * @return array
71
     */
72
    public function provides()
73
    {
74
        return [
75
            'arcanedev.excel.exporter',
76
            Contracts\ExporterManager::class,
77
            'arcanedev.excel.importer',
78
            Contracts\ImporterManager::class,
79
        ];
80
    }
81
82
    /* ------------------------------------------------------------------------------------------------
83
     |  Other Functions
84
     | ------------------------------------------------------------------------------------------------
85
     */
86
    /**
87
     * Register the exporter manager.
88
     */
89
    private function registerExporter()
90
    {
91
        $this->singleton('arcanedev.excel.exporter', function ($app) {
92
            return new ExporterFactory($app);
93
        });
94
        $this->bind(Contracts\ExporterManager::class, 'arcanedev.excel.exporter');
95
    }
96
97
    /**
98
     * Register the importer manager.
99
     */
100
    private function registerImporter()
101
    {
102
        $this->singleton('arcanedev.excel.importer', function ($app) {
103
            return new ImporterFactory($app);
104
        });
105
        $this->bind(Contracts\ImporterManager::class, 'arcanedev.excel.importer');
106
    }
107
}
108