LaravelTestimonialsServiceProvider   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 1 Features 2
Metric Value
wmc 7
eloc 43
c 4
b 1
f 2
dl 0
loc 84
ccs 44
cts 44
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 8 1
B boot() 0 62 6
1
<?php
2
3
namespace DavideCasiraghi\LaravelTestimonials;
4
5
use Carbon\Carbon;
6
use Illuminate\Support\ServiceProvider;
7
8
class LaravelTestimonialsServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap the application services.
12
     */
13 34
    public function boot()
14
    {
15
        /*
16
         * Optional methods to load your package assets
17
         */
18 34
        $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'laravel-testimonials');
19 34
        $this->loadViewsFrom(__DIR__.'/../resources/views', 'laravel-testimonials');
20 34
        $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
21 34
        $this->loadRoutesFrom(__DIR__.'/../routes/web.php');
22
23 34
        if (! class_exists('CreateTestimonialsTable')) {
24 1
            $this->publishes([
25 1
                __DIR__.'/../database/migrations/create_testimonials_table.php.stub' => database_path('migrations/'.Carbon::now()->format('Y_m_d_Hmsu').'_create_testimonials_table.php'),
26 1
            ], 'migrations');
27
        }
28 34
        if (! class_exists('CreateTestimonialTranslationsTable')) {
29 1
            $this->publishes([
30 1
                __DIR__.'/../database/migrations/create_testimonial_translations_table.php.stub' => database_path('migrations/'.Carbon::now()->format('Y_m_d_Hmsu').'_create_testimonial_translations_table.php'),
31 1
            ], 'migrations');
32
        }
33 34
        if (! class_exists('CreateTestimonialGroupsTable')) {
34 1
            $this->publishes([
35 1
                __DIR__.'/../database/migrations/create_testimonial_groups_table.php.stub' => database_path('migrations/'.Carbon::now()->format('Y_m_d_Hmsu').'_create_testimonial_groups_table.php'),
36 1
            ], 'migrations');
37
        }
38 34
        if (! class_exists('CreateTestimonialGroupTranslationsTable')) {
39 1
            $this->publishes([
40 1
                __DIR__.'/../database/migrations/create_testimonial_group_translations_table.php.stub' => database_path('migrations/'.Carbon::now()->format('Y_m_d_Hmsu').'_create_testimonial_group_translations_table.php'),
41 1
            ], 'migrations');
42
        }
43
44 34
        if ($this->app->runningInConsole()) {
45 34
            $this->publishes([
46 34
                __DIR__.'/../config/config.php' => config_path('laravel-testimonials.php'),
47 34
            ], 'config');
48
49
            // Publishing the views.
50 34
            $this->publishes([
51 34
                __DIR__.'/../resources/views' => resource_path('views/vendor/laravel-testimonials'),
52 34
            ], 'views');
53
54 34
            $this->publishes([
55 34
                __DIR__.'/../resources/assets/sass' => resource_path('sass/vendor/laravel-testimonials/'),
56 34
            ], 'sass');
57
58 34
            $this->publishes([
59 34
                __DIR__.'/../resources/assets/js' => resource_path('js/vendor/laravel-testimonials/'),
60 34
            ], 'js');
61
62 34
            $this->publishes([
63 34
                __DIR__.'/../resources/assets/images' => public_path('vendor/laravel-testimonials/assets/images/'),
64 34
            ], 'images');
65
66
            // Publishing assets.
67
            /*$this->publishes([
68
                __DIR__.'/../resources/assets' => public_path('vendor/laravel-testimonials'),
69
            ], 'assets');*/
70
71
            // Publishing the translation files.
72 34
            $this->publishes([
73 34
                __DIR__.'/../resources/lang' => resource_path('lang/vendor/laravel-testimonials'),
74 34
            ], 'lang');
75
76
            // Registering package commands.
77
            // $this->commands([]);
78
        }
79 34
    }
80
81
    /**
82
     * Register the application services.
83
     */
84 34
    public function register()
85
    {
86
        // Automatically apply the package configuration
87 34
        $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'laravel-testimonials');
88
89
        // Register the main class to use with the facade
90
        $this->app->singleton('laravel-testimonials', function () {
91 2
            return new LaravelTestimonials;
92 34
        });
93 34
    }
94
}
95