Completed
Push — master ( f4d621...ffcbf3 )
by Aimeos
02:29
created

AuthorizeResponse   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 1
dl 0
loc 37
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A isSuccessful() 0 4 1
A isRedirect() 0 4 3
A getRedirectUrl() 0 4 1
A getTransactionReference() 0 4 1
A getMessage() 0 14 3
1
<?php
2
3
namespace Omnipay\Sofort\Message;
4
5
use Omnipay\Common\Message\RedirectResponseInterface;
6
7
class AuthorizeResponse extends AbstractResponse implements RedirectResponseInterface
8
{
9
    public function isSuccessful()
10
    {
11
        return isset($this->data->transaction);
12
    }
13
    
14
    public function isRedirect()
15
    {
16
        return isset($this->data->transaction) && isset($this->data->payment_url) && !isset($this->data->errors);
17
    }
18
19
    public function getRedirectUrl()
20
    {
21
        return (string) $this->data->payment_url;
22
    }
23
24
    public function getTransactionReference()
25
    {
26
        return (string) $this->data->transaction;
27
    }
28
29
    public function getMessage()
30
    {
31
        if (false === $this->isRedirect()) {
32
            $message = '';
33
34
            foreach ($this->data->error as $error) {
35
                $message .= $error->code . ': ' . $error->message . ' ';
36
            }
37
38
            return $message;
39
        }
40
41
        return null;
42
    }
43
}
44