Test Failed
Pull Request — develop (#41)
by Yuji
04:41
created

UpdateOrderInfoRequest::getParams()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
4
namespace Shippinno\YahooShoppingJp\Request;
5
6
7
use FluidXml\FluidXml;
8
use LogicException;
9
use Shippinno\YahooShoppingJp\Api\UpdateOrderInfoApi;
10
use Shippinno\YahooShoppingJp\Enum\PayType;
11
use Shippinno\YahooShoppingJp\Enum\SuspectFlag;
12
use Shippinno\YahooShoppingJp\Response\UpdateOrderInfoResponse;
13
14
class UpdateOrderInfoRequest extends AbstractRequest
15
{
16
17
    /**
18
     * @return UpdateOrderInfoApi
19
     */
20
    public function api()
21
    {
22
        return new UpdateOrderInfoApi;
23
    }
24
25
    /**
26
     * @return UpdateOrderInfoResponse
27
     */
28
    public function response()
29
    {
30
        return new UpdateOrderInfoResponse;
31
    }
32
33
    /**
34
     * @return void
35
     */
36
    protected function validateParams()
37
    {
38
    }
39
40
    /**
41
     * @return string
42
     */
43
    public function getParams()
44
    {
45
        $this->setIsSeen();
46
        $this->validateParams();
47
48
        $fluidXml = new FluidXml('Req');
49
        $fluidXml->add($this->params);
50
51
        return $fluidXml->xml();
52
    }
53
54
    /**
55
     * 閲覧済みフラグ
56
     * 更新する時必ずtrue
57
     *
58
     * @return bool
59
     */
60
    public function setIsSeen(): self
61
    {
62
        $this->params['Order']['IsSeen'] = true;
63
        return $this;
64
    }
65
66
    /**
67
     * 悪戯フラグ
68
     *
69
     * @param SuspectFlag $suspectFlag
70
     * @return UpdateOrderInfoRequest
71
     */
72 View Code Duplication
    public function setSuspect(SuspectFlag $suspectFlag): self
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
73
    {
74
        if (isset($this->params['Order']['Suspect'])) {
75
            throw new LogicException('Suspect is already set.');
76
        }
77
        $this->params['Order']['Suspect'] = $suspectFlag->getValue();
78
79
        return $this;
80
81
    }
82
83
    /**
84
     * 支払い分類
85
     *
86
     * @param PayType $payType
87
     * @return UpdateOrderInfoRequest
88
     */
89 View Code Duplication
    public function setPayType(PayType $payType): self
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
90
    {
91
        if (isset($this->params['Order']['PayType'])) {
92
            throw new LogicException('PayType is already set.');
93
        }
94
        $this->params['Order']['PayType'] = $payType->getValue();
95
96
        return $this;
97
98
    }
99
}