BaseDataTrait   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 0
dl 0
loc 69
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
getData() 0 1 ?
A getCode() 0 6 2
A getMessage() 0 6 2
A getStatus() 0 6 2
A getTransactionReference() 0 6 2
A isSuccessful() 0 6 1
1
<?php
2
3
namespace Omnipay\BillPay\Message\ResponseData;
4
5
use SimpleXMLElement;
6
7
/**
8
 * Access base data in the response, internal usage only
9
 *
10
 * @author    Andreas Lange <[email protected]>
11
 * @copyright 2016, Connox GmbH
12
 * @license   MIT
13
 */
14
trait BaseDataTrait
15
{
16
    /**
17
     * Response code
18
     *
19
     * @return null|string A response code from the payment gateway
20
     */
21 2
    public function getCode()
22
    {
23 2
        $data = $this->getData();
24
25 2
        return (string)$data['error_code'] ? : null;
26
    }
27
28
    /**
29
     * @return SimpleXMLElement
30
     *
31
     * @codeCoverageIgnore
32
     */
33
    abstract public function getData();
34
35
    /**
36
     * Response Message
37
     *
38
     * @return null|string A response message from the payment gateway
39
     */
40 5
    public function getMessage()
41
    {
42 5
        $data = $this->getData();
43
44 5
        return (string)$data['customer_message'] ? : null;
45
    }
46
47
    /**
48
     * Status information of the response i.e. APPROVED
49
     *
50
     * @return null|string
51
     */
52 1
    public function getStatus()
53
    {
54 1
        $data = $this->getData();
55
56 1
        return (string)$data['status'] ? : null;
57
    }
58
59
    /**
60
     * Gateway Reference
61
     *
62
     * @return null|string A reference provided by the gateway to represent this transaction
63
     */
64 2
    public function getTransactionReference()
65
    {
66 2
        $data = $this->getData();
67
68 2
        return (string)$data['bptid'] ? : null;
69
    }
70
71
    /**
72
     * Is the response successful?
73
     *
74
     * @return bool
75
     */
76 7
    public function isSuccessful()
77
    {
78 7
        $data = $this->getData();
79
80 7
        return (string)$data['error_code'] === '0';
81
    }
82
}
83