Completed
Pull Request — master (#37)
by Vitaliy
30:07 queued 26:47
created

PaymentMessage   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 10
c 3
b 0
f 1
lcom 1
cbo 1
dl 0
loc 68
ccs 0
cts 36
cp 0
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getPurchase() 0 4 1
A getTransaction() 0 4 1
A getPaymentId() 0 4 1
A getExternalPaymentId() 0 6 2
A getPaymentDetails() 0 4 1
A getCustomParameters() 0 8 2
A isDryRun() 0 8 2
1
<?php
2
3
namespace Xsolla\SDK\Webhook\Message;
4
5
class PaymentMessage extends Message
6
{
7
    /**
8
     * @return array
9
     */
10
    public function getPurchase()
11
    {
12
        return $this->request['purchase'];
13
    }
14
15
    /**
16
     * @return array
17
     */
18
    public function getTransaction()
19
    {
20
        return $this->request['transaction'];
21
    }
22
23
    /**
24
     * @return int
25
     */
26
    public function getPaymentId()
27
    {
28
        return $this->request['transaction']['id'];
29
    }
30
31
    /**
32
     * @return string|null
33
     */
34
    public function getExternalPaymentId()
35
    {
36
        if (array_key_exists('external_id', $this->request['transaction'])) {
37
            return $this->request['transaction']['external_id'];
38
        }
39
    }
40
41
    /**
42
     * @return array
43
     */
44
    public function getPaymentDetails()
45
    {
46
        return $this->request['payment_details'];
47
    }
48
49
    /**
50
     * @return array
51
     */
52
    public function getCustomParameters()
53
    {
54
        if (!array_key_exists('custom_parameters', $this->request)) {
55
            return array();
56
        }
57
58
        return $this->request['custom_parameters'];
59
    }
60
61
    /**
62
     * @return bool
63
     */
64
    public function isDryRun()
65
    {
66
        if (!array_key_exists('dry_run', $this->request['transaction'])) {
67
            return false;
68
        }
69
70
        return (bool) $this->request['transaction']['dry_run'];
71
    }
72
}
73