OrderInfoResponder::success()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 11
rs 9.9666
cc 1
nc 1
nop 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * Api Class
6
 * @category    Ticaje
7
 * @author      Max Demian <[email protected]>
8
 */
9
10
namespace Ticaje\AeSdk\Api\Artifact\Responder\Get;
11
12
use Ticaje\Contract\Patterns\Interfaces\Pool\WorkerInterface;
13
use Ticaje\Contract\Patterns\Interfaces\Decorator\Responder\ResponseInterface as ContractResponseInterface;
14
15
use Ticaje\AeSdk\Api\Interfaces\ApiResponderInterface;
16
use Ticaje\AeSdk\Api\Artifact\Responder\Responder;
17
18
/**
19
 * Class OrderInfoResponder
20
 * @package Ticaje\AeSdk\Api\Artifact\Responder
21
 */
22
class OrderInfoResponder implements ApiResponderInterface, WorkerInterface
23
{
24
    use Responder;
0 ignored issues
show
Bug introduced by
The trait Ticaje\AeSdk\Api\Artifact\Responder\Responder requires the property $msg which is not provided by Ticaje\AeSdk\Api\Artifac...\Get\OrderInfoResponder.
Loading history...
25
26
    private $buyerInfo;
0 ignored issues
show
introduced by
The private property $buyerInfo is not used, and could be removed.
Loading history...
27
28
    private $productsInformation = [];
0 ignored issues
show
introduced by
The private property $productsInformation is not used, and could be removed.
Loading history...
29
30
    private $status;
0 ignored issues
show
introduced by
The private property $status is not used, and could be removed.
Loading history...
31
32
    /**
33
     * @inheritDoc
34
     */
35
    public function process(ContractResponseInterface $response): ApiResponderInterface
36
    {
37
        $content = json_decode($response->getContent());
38
        isset($content->error_response) ? $this->error($content->error_response) : $this->success($content->aliexpress_solution_order_info_get_response);
39
        return $this;
40
    }
41
42
    protected function success(\stdClass $response)
43
    {
44
        $data = $response->result->data;
45
        $message = 'Order info fetched successfully';
46
        $this
47
            ->setSuccess(1)
0 ignored issues
show
Bug introduced by
The method setSuccess() does not exist on Ticaje\AeSdk\Api\Artifac...\Get\OrderInfoResponder. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

47
            ->/** @scrutinizer ignore-call */ 
48
              setSuccess(1)
Loading history...
48
            ->setCode(200)
0 ignored issues
show
Bug introduced by
The method setCode() does not exist on Ticaje\AeSdk\Api\Artifac...\Get\OrderInfoResponder. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

48
            ->/** @scrutinizer ignore-call */ setCode(200)
Loading history...
49
            ->setMessage($message)
0 ignored issues
show
Bug introduced by
The method setMessage() does not exist on Ticaje\AeSdk\Api\Artifac...\Get\OrderInfoResponder. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

49
            ->/** @scrutinizer ignore-call */ setMessage($message)
Loading history...
50
            ->setBuyerInfo($data->buyer_info)
0 ignored issues
show
Bug introduced by
The method setBuyerInfo() does not exist on Ticaje\AeSdk\Api\Artifac...\Get\OrderInfoResponder. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

50
            ->/** @scrutinizer ignore-call */ setBuyerInfo($data->buyer_info)
Loading history...
51
            ->setProductsInformation($data->child_order_list->global_aeop_tp_child_order_dto)
0 ignored issues
show
Bug introduced by
The method setProductsInformation() does not exist on Ticaje\AeSdk\Api\Artifac...\Get\OrderInfoResponder. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

51
            ->/** @scrutinizer ignore-call */ setProductsInformation($data->child_order_list->global_aeop_tp_child_order_dto)
Loading history...
52
            ->setStatus($data->order_status)
0 ignored issues
show
Bug introduced by
The method setStatus() does not exist on Ticaje\AeSdk\Api\Artifac...\Get\OrderInfoResponder. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

52
            ->/** @scrutinizer ignore-call */ setStatus($data->order_status)
Loading history...
53
        ;
54
    }
55
}
56