CompletePurchaseRequest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 21.88 %

Coupling/Cohesion

Components 2
Dependencies 8

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 2
cbo 8
dl 7
loc 32
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 0 18 2
A sendData() 7 7 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Omnipay\Paystation\Message;
4
5
use Omnipay\Common\Exception\InvalidRequestException;
6
7
/**
8
 * Paystation Complete Purchase Request
9
 *
10
 * uses quicklookup service, as described here:
11
 * @link http://www.paystation.co.nz/cms_show_download.php?id=38
12
 */
13
class CompletePurchaseRequest extends PurchaseRequest
14
{
15
16
    protected $endpoint = "https://payments.paystation.co.nz/lookup/";
17
18 7
    public function getData()
19
    {
20 7
        $query = $this->httpRequest->query;
21 7
        $ti = $query->get('ti'); //transaction reference
22 7
        $ec = $query->get('ec'); //error code
0 ignored issues
show
Unused Code introduced by
$ec is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
23 7
        $em = $query->get('em'); //error message
0 ignored issues
show
Unused Code introduced by
$em is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
24 7
        $ms = $query->get('ms'); //merchant session
0 ignored issues
show
Unused Code introduced by
$ms is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
25 7
        $am = $query->get('am'); //amount
0 ignored issues
show
Unused Code introduced by
$am is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
26 7
        $futurepaytoken = $query->get('futurepaytoken');
0 ignored issues
show
Unused Code introduced by
$futurepaytoken is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
27 7
        if (!$ti) {
28 1
            throw new InvalidRequestException('Transaction reference is missing');
29
        }
30 6
        $data = array();
31 6
        $data['pi'] = $this->getPaystationId();
32 6
        $data['ti'] = $ti;
33
        
34 6
        return $data;
35
    }
36
37 6 View Code Duplication
    public function sendData($data)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
    {
39 6
        $postdata = http_build_query($data);
40 6
        $httpResponse = $this->httpClient->request('GET', $this->getEndPoint('').'&'.$postdata, []);
41
42 6
        return $this->response = new CompletePurchaseResponse($this, $httpResponse->getBody()->getContents());
43
    }
44
}
45