Completed
Pull Request — master (#33)
by
unknown
33:52 queued 30:06
created

EventDispatcher   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 9
c 1
b 0
f 0
dl 0
loc 39
ccs 9
cts 9
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A dispatch() 0 3 1
A fire() 0 3 1
1
<?php namespace Distilleries\Expendable\Events;
2
3
use \Event;
4
use Distilleries\Expendable\Contracts\EventContract;
5
6
class EventDispatcher implements EventContract {
7
8
    protected $event_name;
9
    protected $params = array();
10
11
12
    // ------------------------------------------------------------------------------------------------
13
    // ------------------------------------------------------------------------------------------------
14
    // ------------------------------------------------------------------------------------------------
15
16
17 16
    public function __construct($eventName, $params = array(), $auto_dispatch = true)
18
    {
19 16
        $this->event_name = $eventName;
20 16
        $this->params     = $params;
21
22 16
        if ($auto_dispatch === true)
23
        {
24 14
            $this->dispatch($this->params);
25
        }
26
    }
27
28
    // ------------------------------------------------------------------------------------------------
29
30
    /**
31
     * @inheritDoc
32
     */
33 16
    public function dispatch($params = array())
34
    {
35 16
        Event::dispatch($this->event_name, array($params));
0 ignored issues
show
Bug introduced by
The method dispatch() does not exist on Event. ( Ignorable by Annotation )

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

35
        Event::/** @scrutinizer ignore-call */ 
36
               dispatch($this->event_name, array($params));

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
36
    }
37
38
    /**
39
     * @param  array  $params
40
     * @deprecated Use dispatch instead
41
     */
42 2
    public function fire($params = array())
43
    {
44 2
        $this->dispatch($params);
45
    }
46
}