LaravelFontAwesomeServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace PendoNL\LaravelFontAwesome;
4
5
use Illuminate\Support\Facades\Blade;
6
use Illuminate\Support\ServiceProvider;
7
8
/**
9
 * Class LaravelFontAwesomeServiceProvider.
10
 */
11
class LaravelFontAwesomeServiceProvider extends ServiceProvider
12
{
13
    /**
14
     * Boot method registers the blade directive.
15
     * Usage; @fa('list', ['attributes' => 'go here']).
16
     *
17
     * @return void
18
     */
19
    public function boot()
20
    {
21
        $this->publishes([
22
            __DIR__.'/../publish/config/laravel-fontawesome.php' => config_path('laravel-fontawesome.php'),
23
        ], 'config');
24
25
        Blade::directive('fa', function ($expression) {
26
            return "<?php echo FontAwesome::icon({$expression}); ?>";
27
        });
28
    }
29
30
    /**
31
     * Register the service provider.
32
     *
33
     * @return void
34
     */
35
    public function register()
36
    {
37
        $packageConfigFile = __DIR__.'/../publish/config/laravel-fontawesome.php';
38
39
        $this->mergeConfigFrom(
40
            $packageConfigFile, 'laravel-fontawesome'
41
        );
42
43
        $this->app->singleton('laravel-font-awesome', 'PendoNL\LaravelFontAwesome\LaravelFontAwesome');
44
    }
45
}
46