Test Failed
Push — develop ( fab808...f55317 )
by Yuji
03:48
created

GetOrderInfoRequest   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 104
Duplicated Lines 19.23 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 4
dl 20
loc 104
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 34 1
A api() 0 4 1
A response() 0 4 1
A validateParams() 0 4 1
A getParams() 0 7 1
A setSellerId() 10 10 2
A setOrderId() 10 10 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Shippinno\YahooShoppingJp\Request;
4
5
use FluidXml\FluidXml;
6
use LogicException;
7
use Shippinno\YahooShoppingJp\Api\GetOrderInfoApi;
8
use Shippinno\YahooShoppingJp\Response\GetOrderInfoResponse;
9
10
class GetOrderInfoRequest extends AbstractRequest
11
{
12
13
    public function __construct()
14
    {
15
        $this->params['Target']['Field'] = implode(',', [
16
            'OrderId', 'Version', 'ParentOrderId', 'ChildOrderId', 'DeviceType', 'MobileCarrierName', 'IsSeen',
17
            'IsSplit', 'CancelReason', 'IsRoyalty', 'IsRoyaltyFix', 'IsSeller', 'IsAffiliate', 'IsRatingB2s', 'NeedSnl',
18
            'OrderTime', 'LastUpdateTime', 'Suspect', 'SuspectMessage', 'OrderStatus', 'StoreStatus', 'RoyaltyFixTime',
19
            'SendConfirmTime', 'SendPayTime', 'PrintSlipTime', 'PrintDeliveryTime', 'PrintBillTime', 'BuyerComments',
20
            'SellerComments', 'Notes', 'OperationUser', 'Referer', 'EntryPoint', 'HistoryId', 'HistoryId',
21
            'UseCouponData', 'UseCouponData', 'ShippingCouponFlg', 'ShippingCouponDiscount', 'CampaignPoints',
22
            'PayStatus', 'SettleStatus', 'PayType', 'PayKind', 'PayMethod', 'PayMethodName', 'SellerHandlingCharge',
23
            'PayActionTime', 'PayDate', 'PayNotes', 'SettleId', 'CardBrand', 'CardNumber', 'CardNumberLast4',
24
            'CardExpireYear', 'CardExpireMonth', 'CardPayType', 'CardHolderName', 'CardPayCount', 'CardBirthDay',
25
            'UseYahooCard', 'UseWallet', 'NeedBillSlip', 'NeedDetailedSlip', 'NeedReceipt', 'AgeConfirmField',
26
            'AgeConfirmValue', 'AgeConfirmValue', 'BillAddressFrom', 'BillFirstName', 'BillFirstNameKana',
27
            'BillLastName', 'BillLastNameKana', 'BillZipCode', 'BillPrefecture', 'BillPrefectureKana', 'BillCity',
28
            'BillCityKana', 'BillAddress1', 'BillAddress1Kana', 'BillAddress2', 'BillAddress2Kana', 'BillPhoneNumber',
29
            'BillEmgPhoneNumber', 'BillMailAddress', 'BillSection1Field', 'BillSection1Value', 'BillSection2Field',
30
            'BillSection2Value', 'PayNo', 'PayNoIssueDate', 'ConfirmNumber', 'PaymentTerm', 'ShipStatus', 'ShipMethod',
31
            'ShipMethodName', 'ShipRequestDate', 'ShipRequestTime', 'ShipNotes', 'ShipInvoiceNumber1',
32
            'ShipInvoiceNumber2', 'ShipUrl', 'ArriveType', 'ShipDate', 'ArrivalDate', 'NeedGiftWrap', 'GiftWrapType',
33
            'GiftWrapMessage', 'NeedGiftWrapPaper', 'GiftWrapPaperType', 'GiftWrapName', 'Option1Field', 'Option1Type',
34
            'Option1Value', 'Option2Field', 'Option2Type', 'Option2Value', 'ShipFirstName', 'ShipFirstNameKana',
35
            'ShipLastName', 'ShipLastNameKana', 'ShipZipCode', 'ShipPrefecture', 'ShipPrefectureKana', 'ShipCity',
36
            'ShipCityKana', 'ShipAddress1', 'ShipAddress1Kana', 'ShipAddress2', 'ShipAddress2Kana', 'ShipPhoneNumber',
37
            'ShipEmgPhoneNumber', 'ShipSection1Field', 'ShipSection1Value', 'ShipSection2Field', 'ShipSection2Value',
38
            'PayCharge', 'ShipCharge', 'GiftWrapCharge', 'Discount', 'Adjustments', 'SettleAmount', 'UsePoint',
39
            'TotalPrice', 'SettlePayAmount', 'TaxRatio', 'IsGetPointFixAll', 'TotalMallCouponDiscount', 'LineId',
40
            'ItemId', 'Title', 'SubCode', 'SubCodeOption', 'ItemOption', 'Inscription', 'IsUsed', 'ImageId', 'IsTaxable',
41
            'Jan', 'ProductId', 'CategoryId', 'AffiliateRatio', 'UnitPrice', 'Quantity', 'PointAvailQuantity',
42
            'ReleaseDate', 'IsShippingFree', 'HaveReview', 'PointFspCode', 'PointRatioY', 'PointRatioSeller',
43
            'UnitGetPoint', 'IsGetPointFix', 'GetPointFixDate', 'CouponData', 'CouponDiscount', 'CouponUseNum',
44
            'OriginalPrice', 'OriginalNum', 'SellerId', 'IsLogin', 'FspLicenseCode', 'FspLicenseName', 'GuestAuthId',
45
        ]);
46
    }
47
48
    /**
49
     * @return GetOrderInfoApi
50
     */
51
    public function api()
52
    {
53
        return new GetOrderInfoApi;
54
    }
55
56
    /**
57
     * @return GetOrderInfoResponse
58
     */
59
    public function response()
60
    {
61
        return new GetOrderInfoResponse;
62
    }
63
64
    /**
65
     * @return void
66
     */
67
    protected function validateParams()
68
    {
69
        // TODO: Implement validateParams() method.
70
    }
71
72
    /**
73
     * @return array
74
     */
75
    public function getParams()
76
    {
77
        $fluidXml = new FluidXml('Req');
78
        $fluidXml->add($this->params);
79
80
        return $fluidXml->xml();
81
    }
82
83
    /**
84
     * @param string $sellerId
85
     * @return self
86
     */
87 View Code Duplication
    public function setSellerId(string $sellerId): 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...
88
    {
89
        if (isset($this->params['SellerId'])) {
90
            throw new LogicException('SellerId is already set.');
91
        }
92
93
        $this->params['SellerId'] = $sellerId;
94
95
        return $this;
96
    }
97
98
    /**
99
     * @param string $orderId
100
     * @return self
101
     */
102 View Code Duplication
    public function setOrderId(string $orderId): 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...
103
    {
104
        if (isset($this->params['Target']['OrderId'])) {
105
            throw new LogicException('OrderId is already set.');
106
        }
107
108
        $this->params['Target']['OrderId'] = $orderId;
109
110
        return $this;
111
    }
112
113
}
114