LaravelMailLogServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 2
eloc 7
c 2
b 1
f 0
nc 2
nop 0
dl 0
loc 12
rs 10
1
<?php
2
3
namespace Giuga\LaravelMailLog;
4
5
use Giuga\LaravelMailLog\Commands\ClearOldEmails;
6
use Illuminate\Support\ServiceProvider;
7
8
class LaravelMailLogServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap the application services.
12
     */
13
    public function boot()
14
    {
15
        $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
16
17
        if ($this->app->runningInConsole()) {
18
            // Publishing the config.
19
            $this->publishes([
20
                __DIR__.'/../config/config.php' => config_path('mail-log.php'),
21
            ], 'maillog-config');
22
23
            $this->commands([
24
                ClearOldEmails::class,
25
            ]);
26
        }
27
    }
28
29
    /**
30
     * Register the application services.
31
     */
32
    public function register()
33
    {
34
        $this->app->register(MailEventServiceProvider::class);
35
        $this->app->register(MailPolicyServiceProvider::class);
36
37
        // Automatically apply the package configuration
38
        $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'mail-log');
39
40
        // Register the main class to use with the facade
41
        $this->app->singleton('laravel-mail-log', function () {
42
            return new LaravelMailLog;
43
        });
44
    }
45
}
46