PurchaseResponse   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 6
eloc 8
c 4
b 0
f 0
dl 0
loc 22
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getRedirectUrl() 0 8 3
A isSuccessful() 0 2 1
A isRedirect() 0 2 1
A getRedirectData() 0 2 1
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
        return false;
16
    }
17
18
    public function isRedirect() {
19
        return true;
20
    }
21
22
    public function getRedirectUrl() {
23
        foreach ( $this->data->links ?? [] as $link ) {
24
            if ($link->rel === 'hpp') {
25
                return $link->href;
26
            }
27
        }
28
29
        throw new InvalidResponseException('Invalid response from windcave server');
30
    }
31
32
    public function getRedirectData() {
33
        return [];
34
    }
35
}