Passed
Push — master ( f43d04...c61266 )
by Iman
06:27
created

ChainManager   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 15
dl 0
loc 43
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 3 1
A set() 0 3 1
A push() 0 3 1
A submitChainConfig() 0 4 1
A commitCalledMethod() 0 4 1
A startChain() 0 8 1
1
<?php
2
3
namespace Imanghafoori\HeyMan;
4
5
use Imanghafoori\HeyMan\Reactions\ReactionFactory;
6
7
class ChainManager
8
{
9
    /**
10
     * @var \Imanghafoori\HeyMan\Chain
11
     */
12
    private $chain;
13
14
    public function startChain()
15
    {
16
        $this->chain = new Chain();
17
        $this->chain->chainInfo = [
0 ignored issues
show
Documentation Bug introduced by
It seems like array('beforeReaction' =...ng', 'data' => array()) of type array<string,array|array<string,string>|string> is incompatible with the declared type Imanghafoori\HeyMan\ListenerApplier of property $chainInfo.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
18
            'beforeReaction' => [],
19
            'debugInfo'      => ['file' => '', 'line' => '', 'args' => ''],
20
            'responseType'   => 'nothing',
21
            'data'           => [],
22
        ];
23
    }
24
25
    public function submitChainConfig()
26
    {
27
        $callbackListener = resolve(ReactionFactory::class)->make();
28
        $this->get('eventManager')->commitChain($callbackListener);
29
    }
30
31
    public function commitCalledMethod($args, $methodName)
32
    {
33
        $this->push('data', $args);
34
        $this->set('responseType', $methodName);
35
    }
36
37
    public function get($key)
38
    {
39
        return $this->chain->chainInfo[$key] ?? null;
40
    }
41
42
    public function set($key, $value)
43
    {
44
        $this->chain->chainInfo[$key] = $value;
45
    }
46
47
    public function push($key, $value)
48
    {
49
        $this->chain->chainInfo[$key][] = $value;
50
    }
51
}
52