Passed
Branch master (7fc895)
by João Felipe Magro
03:00
created

ApiActionService::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 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
0 ignored issues
show
Bug introduced by
The type Ipag\Classes\Services\stdClass was not found. Did you mean stdClass? If so, make sure to prefix the type with \.
Loading history...
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();
0 ignored issues
show
Bug introduced by
The method getTransaction() does not exist on Ipag\Classes\Contracts\Serializable. It seems like you code against a sub-type of Ipag\Classes\Contracts\Serializable such as Ipag\Classes\Serializer\Serializer or Ipag\Classes\Serializer\PaymentSerializer. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

37
        /** @scrutinizer ignore-call */ 
38
        $transaction = $this->serializer->getTransaction();
Loading history...
38
39
        $transaction->getOrder()->setOperation($this->serializer->getOperation());
0 ignored issues
show
Bug introduced by
The method getOperation() does not exist on Ipag\Classes\Contracts\Serializable. It seems like you code against a sub-type of Ipag\Classes\Contracts\Serializable such as Ipag\Classes\Order or Ipag\Classes\Serializer\Serializer or Ipag\Classes\Serializer\PaymentSerializer. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
        $transaction->getOrder()->setOperation($this->serializer->/** @scrutinizer ignore-call */ getOperation());
Loading history...
40
41
        $action = $this->serializer->getAction();
0 ignored issues
show
Bug introduced by
The method getAction() does not exist on Ipag\Classes\Contracts\Serializable. It seems like you code against a sub-type of Ipag\Classes\Contracts\Serializable such as Ipag\Classes\Serializer\Serializer or Ipag\Classes\Serializer\PaymentSerializer. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

41
        /** @scrutinizer ignore-call */ 
42
        $action = $this->serializer->getAction();
Loading history...
42
43
        $response = $transaction->sendHttpRequest(
44
            $transaction->getIpag()->getEndpoint()->$action(),
45
            $this->serializer->serialize()
46
        );
47
48
        return $transaction->populate($response);
49
    }
50
}
51