Passed
Push — master ( 01baf6...9ed857 )
by Vitor de
04:10
created

CommandBus   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 50
ccs 16
cts 16
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getManager() 0 4 1
A receive() 0 13 1
A send() 0 4 1
1
<?php
2
3
namespace GFG\Hek;
4
5
class CommandBus
6
{
7
    /**
8
     * @var Manager
9
     */
10
    private $manager;
11
12
    /**
13
     * @param Manager $manager
14
     */
15 3
    public function __construct(Manager $manager)
16
    {
17 3
        $this->manager = $manager;
18 3
    }
19
20
    /**
21
     * @return Manager
22
     */
23 3
    public function getManager()
24
    {
25 3
        return $this->manager;
26
    }
27
28
    /**
29
     * @param array $dtoData
30
     * @return mixed
31
     */
32 1
    public function receive(array $dtoData)
33
    {
34 1
        $context = $this->getManager()->getContextManager()->rebuild(
35 1
            $dtoData,
36 1
            $this->getManager()->getContextManager()->getHydrator()
37 1
        );
38
39 1
        $explode = explode('.', $context->getName());
40 1
        $action  = end($explode);
41 1
        $service = $this->getManager()->getServiceFactory()->build($context);
42
43 1
        return $service->$action($context);
44
    }
45
46
    /**
47
     * @param Interfaces\Context $context
48
     * @return mixed
49
     */
50 1
    public function send(Interfaces\Context $context)
51
    {
52 1
        return $this->getManager()->getApiClient()->execute($context);
53
    }
54
}
55