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

EventDispatcher::firing()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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