getTransactionReference()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
nc 2
nop 0
dl 0
loc 4
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Omnipay\GoCardless\Message;
4
5
use Omnipay\Common\Message\AbstractResponse;
6
use Omnipay\Common\Message\RedirectResponseInterface;
7
8
/**
9
 * GoCardless Redirect Complete Flow Response
10
 */
11
class RedirectCompleteFlowResponse extends AbstractResponse implements RedirectResponseInterface
12
{
13
    public function isSuccessful()
14
    {
15
        return !isset($this->data['error']) && isset($this->data['redirect_flows']);
16
    }
17
18
    public function isRedirect()
19
    {
20
        return false;
21
    }
22
23
    public function getTransactionReference()
24
    {
25
        if ($this->isSuccessful()) {
26
            return $this->data['redirect_flows']['id'];
27
        }
28
    }
29
30
    public function getMessage()
31
    {
32
        if (!$this->isSuccessful()) {
33
            return $this->data['error']['message'];
34
        }
35
    }
36
37
    public function getRedirectUrl()
38
    {
39
        if ($this->isSuccessful()) {
40
            return $this->data['redirect_flows']['confirmation_url'];
41
        }
42
    }
43
44
    public function getRedirectMethod()
45
    {
46
        return 'GET';
47
    }
48
49
    public function getRedirectData()
50
    {
51
        return null;
52
    }
53
54
    public function getMandateId()
55
    {
56
        if ($this->isSuccessful()) {
57
            return $this->data['redirect_flows']['links']['mandate'];
58
        }
59
    }
60
61
    /**
62
     * Treat mandate as a 'card' to support createCard pattern
63
     */
64
    public function getCardReference()
65
    {
66
        return $this->getMandateId();
67
    }
68
}
69