Passed
Push — master ( 84ac3f...3b83f4 )
by Iman
07:14
created

ChainManager   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
eloc 13
dl 0
loc 37
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A submitChainConfig() 0 4 1
A startChain() 0 8 1
A get() 0 3 1
A set() 0 3 1
A push() 0 3 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 105
    public function startChain()
15
    {
16 105
        $this->chain = new Chain();
17 105
        $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 105
    }
24
25 96
    public function submitChainConfig()
26
    {
27 96
        $callbackListener = resolve(ReactionFactory::class)->make();
28 96
        $this->get('eventManager')->commitChain($callbackListener);
29 96
    }
30
31 90
    public function get($key)
32
    {
33 90
        return $this->chain->chainInfo[$key] ?? null;
34 90
    }
35 90
36
    public function set($key, $value)
37 104
    {
38
        $this->chain->chainInfo[$key] = $value;
39 104
    }
40
41
    public function push($key, $value)
42 104
    {
43
        $this->chain->chainInfo[$key][] = $value;
44 104
    }
45
}
46