Action   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
eloc 10
dl 0
loc 28
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A fire() 0 16 6
1
<?php
2
3
namespace EventyClassic;
4
5
class Action extends Event
6
{
7
    /**
8
     * Runs an action.
9
     *
10
     * When an action is fired, all listeners are run in the order supplied when adding them.
11
     *
12
     * @param  string $action Name of action.
13
     * @param  array  $args   Arguments passed to the filter.
14
     *
15
     * @return void
16
     */
17 5
    public function fire($action, $args)
18
    {
19 5
        if ($this->getListeners()) {
20 5
            $listeners = $this->getListeners();
21
22 5
            foreach ($listeners as $listener) {
23 5
                if ($listener['hook'] == $action) {
24 5
                    $parameters = [];
25
26 5
                    for ($i = 0; $i < $listener['arguments']; $i++) {
27 5
                        if (isset($args[$i])) {
28 1
                            $parameters[] = $args[$i];
29
                        }
30
                    }
31
32 5
                    call_user_func_array($this->getFunction($listener['callback']), $parameters);
33
                }
34
            }
35
        }
36 4
    }
37
}
38