Completed
Pull Request — master (#11)
by ARCANEDEV
06:25
created

EventServiceProvider::boot()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

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