Completed
Push — master ( badfda...dd97a5 )
by Maxime
20s queued 10s
created

EventDispatcher::dispatch()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 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
}