Completed
Push — master ( d2b3f3...05ef8e )
by João Felipe Magro
02:25
created

BaseService::setTransaction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Ipag\Classes\Services;
4
5
use Ipag\Classes\Contracts\Serializable;
6
use Ipag\Classes\Transaction;
7
8
abstract class BaseService
9
{
10
    /**
11
     * @var Transaction
12
     */
13
    private $transaction;
14
15
    /**
16
     * @var Serializer
17
     */
18
    private $serializer;
19
20
    /**
21
     * @var string
22
     */
23
    private $operation;
24
25
    /**
26
     * @var string
27
     */
28
    private $action;
29
30
    public function __construct(Transaction $transaction)
31
    {
32
        $this->transaction = $transaction;
33
    }
34
35
    public function executeAction()
36
    {
37
        $this->transaction->getOrder()->setOperation($this->getOperation());
38
39
        $action = $this->getAction();
40
41
        $response = $this->transaction->sendHttpRequest(
42
            $this->transaction->getIpag()->getEndpoint()->$action(),
43
            $this->serializer->serialize()
44
        );
45
46
        return $this->transaction->populate($response);
47
    }
48
49
    /**
50
     * @param Serializable $serializer
51
     */
52
    public function setSerializer(Serializable $serializer)
53
    {
54
        $this->serializer = $serializer;
0 ignored issues
show
Documentation Bug introduced by
It seems like $serializer of type object<Ipag\Classes\Contracts\Serializable> is incompatible with the declared type object<Ipag\Classes\Services\Serializer> of property $serializer.

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...
55
56
        return $this;
57
    }
58
59
    /**
60
     * @return Transaction
61
     */
62
    public function getTransaction()
63
    {
64
        return $this->transaction;
65
    }
66
67
    /**
68
     * @return string
69
     */
70
    public function getOperation()
71
    {
72
        return $this->operation;
73
    }
74
75
    /**
76
     * @param string $operation
77
     */
78
    public function setOperation($operation)
79
    {
80
        $this->operation = $operation;
81
82
        return $this;
83
    }
84
85
    /**
86
     * @return string
87
     */
88
    public function getAction()
89
    {
90
        return $this->action;
91
    }
92
93
    /**
94
     * @param string $action
95
     */
96
    public function setAction($action)
97
    {
98
        $this->action = $action;
99
100
        return $this;
101
    }
102
}
103