ApiActionService   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 13
c 1
b 0
f 0
dl 0
loc 43
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 3 1
A executeAction() 0 16 1
A setSerializer() 0 5 1
1
<?php
2
3
namespace Ipag\Classes\Services;
4
5
use Ipag\Classes\Contracts\Operationable;
6
use Ipag\Classes\Contracts\Serializable;
7
8
final class ApiActionService implements Operationable
9
{
10
    /**
11
     * @var Serializable
12
     */
13
    private $serializer;
14
15
    /**
16
     * @param Serializable $serializer
17
     */
18
    public function setSerializer(Serializable $serializer)
19
    {
20
        $this->serializer = $serializer;
21
22
        return $this;
23
    }
24
25
    /**
26
     * @param Serializable $serializer
27
     *
28
     * @return \stdClass
29
     */
30
    public function execute(Serializable $serializer)
31
    {
32
        return $this->setSerializer($serializer)->executeAction();
33
    }
34
35
    public function executeAction()
36
    {
37
        $transaction = $this->serializer->getTransaction();
38
39
        $transaction->getOrder()->setOperation($this->serializer->getOperation());
40
41
        $action = $this->serializer->getAction();
42
43
        $transaction->authenticate();
44
45
        $response = $transaction->sendHttpRequest(
46
            $transaction->getIpag()->getEndpoint()->$action(),
47
            $this->serializer->serialize()
48
        );
49
50
        return $transaction->populate($response);
51
    }
52
}
53