EventServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 6
dl 0
loc 39
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 6 1
A registerCommands() 0 8 1
A registerBindings() 0 14 1
1
<?php namespace Nwidart\LaravelBroadway\Broadway;
2
3
use Broadway\EventDispatcher\CallableEventDispatcher;
4
use Broadway\EventHandling\SimpleEventBus;
5
use Illuminate\Support\ServiceProvider;
6
use Nwidart\LaravelBroadway\Console\CreateEventStoreCommand;
7
use Nwidart\LaravelBroadway\Registries\EventRegistry;
8
9
class EventServiceProvider extends ServiceProvider
10
{
11
    public function register()
12
    {
13
        $this->registerBindings();
14
15
        $this->registerCommands();
16
    }
17
18
    /**
19
     * Register artisan command to generate the event store table
20
     */
21
    private function registerCommands()
22
    {
23
        $this->app->singleton('laravel-broadway::event-store::migrate', function () {
24
            return new CreateEventStoreCommand();
25
        });
26
27
        $this->commands('laravel-broadway::event-store::migrate');
28
    }
29
30
    /**
31
     * Register bindings on the IoC Container
32
     */
33
    private function registerBindings()
34
    {
35
        $this->app->singleton(\Broadway\EventDispatcher\EventDispatcher::class, function () {
36
            return new CallableEventDispatcher();
37
        });
38
39
        $this->app->singleton(\Broadway\EventHandling\EventBus::class, function () {
40
            return new SimpleEventBus();
41
        });
42
43
        $this->app->singleton('laravelbroadway.event.registry', function ($app) {
44
            return new EventRegistry($app[\Broadway\EventHandling\EventBus::class]);
45
        });
46
    }
47
}
48