PromiseTemplateListResponder::success()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 7
c 1
b 0
f 1
dl 0
loc 9
rs 10
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 PromiseTemplateListResponder
20
 * @package Ticaje\AeSdk\Api\Artifact\Responder\Get
21
 */
22
class PromiseTemplateListResponder 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...seTemplateListResponder.
Loading history...
25
26
    private $count;
0 ignored issues
show
introduced by
The private property $count is not used, and could be removed.
Loading history...
27
28
    private $templates = [];
0 ignored issues
show
introduced by
The private property $templates is not used, and could be removed.
Loading history...
29
30
    /**
31
     * @inheritDoc
32
     */
33
    public function process(ContractResponseInterface $response): ApiResponderInterface
34
    {
35
        $content = json_decode($response->getContent())->aliexpress_postproduct_redefining_querypromisetemplatebyid_response->result;
36
        isset($content->error_code) ? $this->error($content) : $this->success($content);
37
        return $this;
38
    }
39
40
    // {"aliexpress_postproduct_redefining_querypromisetemplatebyid_response":{"result":{"template_list":{"templatelist":[{"id":0,"name":"Service Template for New Sellers"}]}},"request_id":"6q1kgx1ihhw7"}}
41
    protected function success(\stdClass $response)
42
    {
43
        $data = $response->template_list;
44
        $this
45
            ->setSuccess(1)
0 ignored issues
show
Bug introduced by
The method setSuccess() does not exist on Ticaje\AeSdk\Api\Artifac...seTemplateListResponder. 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

45
            ->/** @scrutinizer ignore-call */ 
46
              setSuccess(1)
Loading history...
46
            ->setCount(count($data->templatelist)) // Whatsoever the key is since this is taken on a case by case basis
0 ignored issues
show
Bug introduced by
The method setCount() does not exist on Ticaje\AeSdk\Api\Artifac...seTemplateListResponder. 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

46
            ->/** @scrutinizer ignore-call */ setCount(count($data->templatelist)) // Whatsoever the key is since this is taken on a case by case basis
Loading history...
47
            ->setTemplates($data->templatelist) // Quite the same
0 ignored issues
show
Bug introduced by
The method setTemplates() does not exist on Ticaje\AeSdk\Api\Artifac...seTemplateListResponder. 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 */ setTemplates($data->templatelist) // Quite the same
Loading history...
48
            ->setCode(200)
0 ignored issues
show
Bug introduced by
The method setCode() does not exist on Ticaje\AeSdk\Api\Artifac...seTemplateListResponder. 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('Ok')
0 ignored issues
show
Bug introduced by
The method setMessage() does not exist on Ticaje\AeSdk\Api\Artifac...seTemplateListResponder. 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('Ok')
Loading history...
50
        ;
51
    }
52
}
53