MailboxServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 11
nc 2
nop 0
dl 0
loc 19
rs 9.9
c 2
b 0
f 0
1
<?php
2
3
namespace BeyondCode\Mailbox;
4
5
use BeyondCode\Mailbox\Facades\Mailbox;
6
use BeyondCode\Mailbox\Http\Middleware\MailboxBasicAuthentication;
7
use BeyondCode\Mailbox\Routing\Router;
8
use Illuminate\Support\Facades\Route;
9
use Illuminate\Support\ServiceProvider;
10
11
class MailboxServiceProvider extends ServiceProvider
12
{
13
    /**
14
     * Bootstrap the application services.
15
     */
16
    public function boot()
17
    {
18
        if (! class_exists('CreateMailboxInboundEmailsTable')) {
19
            $this->publishes([
20
                __DIR__.'/../database/migrations/create_mailbox_inbound_emails_table.php.stub' => database_path('migrations/'.date('Y_m_d_His', time()).'_create_mailbox_inbound_emails_table.php'),
21
            ], 'migrations');
22
        }
23
24
        $this->publishes([
25
            __DIR__.'/../config/mailbox.php' => config_path('mailbox.php'),
26
        ], 'config');
27
28
        Route::aliasMiddleware('laravel-mailbox', MailboxBasicAuthentication::class);
29
30
        $this->commands([
31
            Console\CleanEmails::class,
32
        ]);
33
34
        $this->registerDriver();
35
    }
36
37
    /**
38
     * Register the application services.
39
     */
40
    public function register()
41
    {
42
        $this->mergeConfigFrom(__DIR__.'/../config/mailbox.php', 'mailbox');
43
44
        $this->app->singleton('mailbox', function () {
45
            return new Router($this->app);
46
        });
47
48
        $this->app->singleton(MailboxManager::class, function () {
49
            return new MailboxManager($this->app);
50
        });
51
    }
52
53
    protected function registerDriver()
54
    {
55
        Mailbox::mailbox()->register();
0 ignored issues
show
Bug introduced by
The method mailbox() does not exist on BeyondCode\Mailbox\Facades\Mailbox. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

55
        Mailbox::/** @scrutinizer ignore-call */ 
56
                 mailbox()->register();
Loading history...
56
    }
57
}
58