Completed
Push — main ( a57d67...55b4bf )
by Stas
12:57 queued 11:40
created

OrderResponse   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 19
ccs 0
cts 9
cp 0
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parseDataModel() 0 4 2
A getConsumptionState() 0 3 1
1
<?php
2
3
namespace Huawei\IAP\Response;
4
5
/**
6
 * Class OrderResponse
7
 * Response returned in case of Order verification
8
 * @see https://developer.huawei.com/consumer/en/doc/development/HMS-References/iap-api-order-service-purchase-token-verification-v4
9
 *
10
 * @package Huawei\IAP\Response
11
 */
12
class OrderResponse extends ValidationResponse
13
{
14
    protected function parseDataModel(array $raw)
15
    {
16
        if (isset($raw['purchaseTokenData'])) {
17
            $this->dataModel = \json_decode($raw['purchaseTokenData'], true);
18
        }
19
    }
20
21
    /**
22
     * Consumption status, which exists only for one-off products. The options are as follows:
23
     * 0: not consumed
24
     * 1: consumed
25
     *
26
     * @return string|null
27
     */
28
    public function getConsumptionState()
29
    {
30
        return $this->dataModel['consumptionState'] ?? null;
31
    }
32
}
33