EventServiceProvider   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 65
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A listens() 0 4 1
A boot() 0 12 4
A register() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arcanedev\Support\Providers;
6
7
use Illuminate\Support\Facades\Event;
8
9
/**
10
 * Class     EventServiceProvider
11
 *
12
 * @author   ARCANEDEV <[email protected]>
13
 */
14
abstract class EventServiceProvider extends ServiceProvider
15
{
16
    /* -----------------------------------------------------------------
17
     |  Properties
18
     | -----------------------------------------------------------------
19
     */
20
21
    /**
22
     * The event handler mappings for the application.
23
     *
24
     * @var array
25
     */
26
    protected $listen = [];
27
28
    /**
29
     * The subscriber classes to register.
30
     *
31
     * @var array
32
     */
33
    protected $subscribe = [];
34
35
    /* -----------------------------------------------------------------
36
     |  Getters & Setters
37
     | -----------------------------------------------------------------
38
     */
39
40
    /**
41
     * Get the events and handlers.
42
     *
43
     * @return array
44
     */
45
    public function listens()
46
    {
47
        return $this->listen;
48
    }
49
50
    /* -----------------------------------------------------------------
51
     |  Main Methods
52
     | -----------------------------------------------------------------
53
     */
54
55
    /**
56
     * Register the application's event listeners.
57
     */
58
    public function boot()
59
    {
60
        foreach ($this->listens() as $event => $listeners) {
61
            foreach ($listeners as $listener) {
62
                Event::listen($event, $listener);
63
            }
64
        }
65
66
        foreach ($this->subscribe as $subscriber) {
67
            Event::subscribe($subscriber);
68
        }
69
    }
70
71
    /**
72
     * {@inheritdoc}
73
     */
74
    public function register()
75
    {
76
        //
77
    }
78
}
79