Completed
Branch webservice-support (1bfa77)
by John
02:37
created

WebservicePurchaseResponse   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 8
lcom 1
cbo 1
dl 0
loc 46
ccs 0
cts 20
cp 0
rs 10
c 1
b 1
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isSuccessful() 0 9 4
A getTransactionReference() 0 4 1
A getMessage() 0 10 3
1
<?php
2
3
namespace Omnipay\Redsys\Message;
4
5
use SimpleXMLElement;
6
use Omnipay\Common\Message\AbstractResponse;
7
8
/**
9
 * Redsys Purchase Response
10
 */
11
class WebservicePurchaseResponse extends AbstractResponse
12
{
13
    public function isSuccessful()
14
    {
15
        // check for field existence as well as value
16
        return !empty($this->data->CODIGO)
17
            && $this->data->CODIGO == '0'
18
            && !empty($this->data->OPERACION->Ds_Response)
19
            && $this->data->OPERACION->Ds_Response == '0000';
20
        // @todo  && verify signature
21
    }
22
23
    // @todo Other methods required for abstract response
24
    public function getTransactionReference()
25
    {
26
        return "WOOT";
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal WOOT does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
27
    }
28
29
    // @todo Switch to just returning the error code (no message supplied in package)
30
    public function getMessage()
31
    {
32
        if ($this->data instanceof SimpleXMLElement) {
33
            $out = $this->data->asXML();
34
        } else {
35
            $out = json_encode($this->data);
36
        }
37
38
        return is_string($out) ? $out : 'nope';
39
    }
40
41
    // @todo Pull out signature methods for use in webservice request/response validation
42
    // public function getRedirectData()
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
43
    // {
44
        // $security = new Security;
45
        // $redirect_data = array();
0 ignored issues
show
Unused Code Comprehensibility introduced by
56% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
46
        // $redirect_data['Ds_SignatureVersion'] = Security::VERSION;
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
47
        // $redirect_data['Ds_MerchantParameters'] = $security->encodeMerchantParameters($this->data);
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
48
        // $redirect_data['Ds_Signature'] = $security->createSignature(
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
49
        //     $redirect_data['Ds_MerchantParameters'],
0 ignored issues
show
Unused Code Comprehensibility introduced by
84% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
50
        //     $this->data['Ds_Merchant_Order'],
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
51
        //     base64_decode($this->request->getHmacKey())
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
52
        // );
53
54
        // return $redirect_data;
55
    // }
56
}
57