Completed
Push — master ( f66d75...ad4e62 )
by devosc
02:38
created

Event::args()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
ccs 0
cts 0
cp 0
rs 9.4286
cc 1
eloc 4
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 *
4
 */
5
6
namespace Mvc5;
7
8
class Event
9
    implements Event\Event
10
{
11
    /**
12
     *
13
     */
14
    use Event\Model;
15
    use Signal;
16
17
    /**
18
     * @var mixed
19 1
     */
20
    protected $model;
21 1
22 1
    /**
23
     * @param string|null $event
24
     * @param mixed $model
25
     */
26
    public function __construct($event = null, $model = null)
27
    {
28
        $this->event = $event;
29
        $this->model = $model;
30
    }
31
32
    /**
33
     * @return array
34
     */
35
    protected function args()
36
    {
37
        return array_filter([
38
            Arg::EVENT => $this,
39
            Arg::MODEL => $this->model
40
        ]);
41
    }
42
43
    /**
44
     * @param callable $callable
45
     * @param array $args
46
     * @param callable $callback
47
     * @return mixed
48
     */
49
    public function __invoke(callable $callable, array $args = [], callable $callback = null)
50
    {
51
        $model = $this->signal($callable, $this->args() + $args, $callback);
52
53
        null !== $model
54
            && $this->model = $model;
55
56
        return $model;
57
    }
58
}
59