Completed
Push — master ( 5ce56d...36c7f3 )
by WEBEWEB
01:25
created

RequestSerializer::serializeRequestData()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
/*
4
 * This file is part of the core-library package.
5
 *
6
 * (c) 2019 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Library\Core\ThirdParty\Adoria\Serializer;
13
14
use WBW\Library\Core\Argument\Helper\ArrayHelper;
15
use WBW\Library\Core\ThirdParty\Adoria\Model\RequestData;
16
17
/**
18
 * Request serializer.
19
 *
20
 * @author webeweb <https://github.com/webeweb>
21
 * @package WBW\Library\Core\ThirdParty\Adoria\Serializer
22
 */
23
class RequestSerializer {
24
25
    /**
26
     * Request date format.
27
     *
28
     * @var string
29
     */
30
    const REQUEST_DATE_FORMAT = "Y-m-d";
31
32
    /**
33
     * Serialize a request data.
34
     *
35
     * @param RequestData $requestData The request data.
36
     * @return array Returns the serialized parameters.
37
     */
38
    public static function serializeRequestData(RequestData $requestData) {
39
40
        $parameters = [];
41
42
        ArrayHelper::set($parameters, "AnalyticCode", $requestData->getAnalyticCode(), [null]);
43
        if (null !== $requestData->getBuyDateMax()) {
44
            $parameters["BuyDateMax"] = $requestData->getBuyDateMax()->format(self::REQUEST_DATE_FORMAT);
45
        }
46
        ArrayHelper::set($parameters, "IdentificationKey", $requestData->getIdentificationKey(), [null]);
47
48
        return $parameters;
49
    }
50
}
51