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

PaymentMessage::getTransaction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 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