Passed
Push — main ( 007e00...f82f47 )
by
unknown
09:50
created

PurchaseResponse::getRedirectData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Omnipay\WindcaveHpp\Message;
4
5
use Omnipay\Common\Exception\InvalidResponseException;
6
use Omnipay\Common\Message\AbstractResponse;
7
use Omnipay\Common\Message\RedirectResponseInterface;
8
9
/**
10
 * Windcave HPP Redirect Response
11
 */
12
class PurchaseResponse extends AbstractResponse implements RedirectResponseInterface {
13
14
    public function isSuccessful()
15
    {
16
        return false;
17
    }
18
19
    public function isRedirect()
20
    {
21
        return true;
22
    }
23
24
    public function getRedirectUrl()
25
    {
26
        echo '<pre>'; print_r($this->data); echo '</pre>';
27
28
        foreach ( $this->data->links ?? [] as $link ) {
29
            if ( $link->rel === 'hpp' ) {
30
                return $link->href;
31
            }
32
        }
33
34
        throw new InvalidResponseException('Invalid response from windcave server');
35
    }
36
37
    public function getRedirectData()
38
    {
39
        return [
40
        ];
41
    }
42
}