Completed
Pull Request — master (#43)
by Evgeny
11:21
created

EventDispatcher   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 30
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A firing() 0 4 1
A fire() 0 7 1
1
<?php
2
3
namespace Mpociot\CaptainHook;
4
5
use Illuminate\Events\Dispatcher;
6
7
class EventDispatcher extends Dispatcher
8
{
9
    /**
10
      * The event firing stack.
11
      *
12
      * @var array
13
      */
14
    protected $firing = [];
15
16
    /**
17
      * Get the event that is currently firing.
18
      *
19
      * @return string
20
      */
21
    public function firing()
22
    {
23
        return last($this->firing);
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function fire($event, $payload = [], $halt = false)
30
    {
31
        $this->firing[] = $event;
32
        $response = parent::fire($event, $payload);
33
        array_pop($this->firing);
34
        return $response;
35
    }
36
}
37