Completed
Push — master ( c6b6d5...70eeeb )
by Iman
06:33
created

Chain::addRespondFrom()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Imanghafoori\HeyMan;
4
5
class Chain
6
{
7
    /**
8
     * @var \Imanghafoori\HeyMan\ListenerApplier
0 ignored issues
show
Bug introduced by
The type Imanghafoori\HeyMan\ListenerApplier was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
     */
10
    public $eventManager;
11
12
    public $predicate;
13
14
    public $response = [];
15
16
    public $redirect = [];
17
18
    public $exception = [];
19
20
    public $events = [];
21
22
    public $abort;
23
24
    public $calls;
25
26 75
    public $respondFrom;
27
28 75
    public function reset()
29 75
    {
30 75
        $this->redirect = [];
31 75
        $this->exception = [];
32 75
        $this->response = [];
33 75
        $this->predicate = null;
34
        $this->abort = null;
35 4
    }
36
37 4
    public function addRedirect($method, $params)
38 4
    {
39
        $this->redirect[] = [$method, $params];
40 2
    }
41
42 2
    public function addResponse($method, $params)
43 2
    {
44
        $this->response[] = [$method, $params];
45 68
    }
46
47 68
    public function addException(string $className, string $message)
48 68
    {
49
        $this->exception = ['class' => $className, 'message' => $message];
50 2
    }
51
52 2
    public function addAbort($code, string $message, array $headers)
53 2
    {
54
        $this->abort = [$code, $message, $headers];
55 2
    }
56
57 2
    public function addAfterCall($callback, $parameters)
58 2
    {
59
        $this->calls[] = [$callback, $parameters];
60 1
    }
61
62 1
    public function eventFire($event, array $payload, bool $halt)
63 1
    {
64
        $this->events[] = [$event, $payload, $halt];
65 75
    }
66
67 75
    public function addRespondFrom($callback,array $parameters)
68 75
    {
69 75
        $this->respondFrom = [$callback, $parameters];
70
    }
71
72
    public function submitChainConfig()
73
    {
74
        $callbackListener = app(ListenerFactory::class)->make();
75
        $this->eventManager->startGuarding($callbackListener);
76
    }
77
}
78