Completed
Push — master ( cb32ca...f4aa28 )
by ARCANEDEV
25s
created

ServiceProvider::aliases()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 8
ccs 0
cts 7
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php namespace Arcanedev\Support;
2
3
use Illuminate\Contracts\Foundation\Application;
4
use Illuminate\Foundation\AliasLoader;
5
use Arcanedev\Support\Providers\ServiceProvider as BaseServiceProvider;
6
7
/**
8
 * Class     ServiceProvider
9
 *
10
 * @package  Arcanedev\Support\Laravel
11
 * @author   ARCANEDEV <[email protected]>
12
 *
13
 * @deprecated Use `Arcanedev\Support\Providers\ServiceProvider` instead.
14
 */
15
abstract class ServiceProvider extends BaseServiceProvider
16
{
17
    /* -----------------------------------------------------------------
18
     |  Properties
19
     | -----------------------------------------------------------------
20
     */
21
22
    /**
23
     * The application instance.
24
     *
25
     * @var \Illuminate\Foundation\Application
26
     */
27
    protected $app;
28
29
    /**
30
     * The aliases collection.
31
     *
32
     * @var array
33
     */
34
    protected $aliases = [];
35
36
    /**
37
     * Alias loader.
38
     *
39
     * @var \Illuminate\Foundation\AliasLoader
40
     */
41
    private $aliasLoader;
42
43
    /* -----------------------------------------------------------------
44
     |  Constructor
45
     | -----------------------------------------------------------------
46
     */
47
48
    /**
49
     * Create a new service provider instance.
50
     *
51
     * @param  \Illuminate\Contracts\Foundation\Application  $app
52
     */
53
    public function __construct(Application $app)
54
    {
55
        parent::__construct($app);
56
57
        $this->aliasLoader = AliasLoader::getInstance();
58
    }
59
60
    /* -----------------------------------------------------------------
61
     |  Main Methods
62
     | -----------------------------------------------------------------
63
     */
64
65
    /**
66
     * Register the service provider.
67
     */
68
    public function register()
69
    {
70
        //
71
    }
72
73
    /**
74
     * Boot the service provider.
75
     */
76
    public function boot()
77
    {
78
        //
79
    }
80
81
    /**
82
     * Register aliases (Facades).
83
     */
84
    protected function registerAliases()
85
    {
86
        $loader = $this->aliasLoader;
87
88
        $this->app->booting(function() use ($loader) {
89
            foreach ($this->aliases as $class => $alias) {
90
                $loader->alias($class, $alias);
91
            }
92
        });
93
    }
94
95
    /**
96
     * Add an aliases to the loader.
97
     *
98
     * @param  array  $aliases
99
     *
100
     * @return self
101
     */
102
    protected function aliases(array $aliases)
103
    {
104
        foreach ($aliases as $class => $alias) {
105
            $this->alias($class, $alias);
106
        }
107
108
        return $this;
109
    }
110
111
    /**
112
     * Add an alias to the loader.
113
     *
114
     * @param  string  $class
115
     * @param  string  $alias
116
     *
117
     * @return self
118
     */
119
    protected function alias($class, $alias)
120
    {
121
        $this->aliases[$class] = $alias;
122
123
        return $this;
124
    }
125
126
    /* -----------------------------------------------------------------
127
     |  Services
128
     | -----------------------------------------------------------------
129
     */
130
131
    /**
132
     * Get the config repository instance.
133
     *
134
     * @return \Illuminate\Config\Repository
135
     */
136
    protected function config()
137
    {
138
        return $this->app['config'];
139
    }
140
141
    /**
142
     * Get the filesystem instance.
143
     *
144
     * @return \Illuminate\Filesystem\Filesystem
145
     */
146
    protected function filesystem()
147
    {
148
        return $this->app['files'];
149
    }
150
}
151