EventServiceProvider::boot()   A
last analyzed

Complexity

Conditions 4
Paths 6

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
cc 4
nc 6
nop 0
dl 0
loc 12
ccs 0
cts 7
cp 0
crap 20
rs 9.8666
c 0
b 0
f 0
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