GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

DirectLinkQueryResponse   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 58
Duplicated Lines 81.03 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 47
loc 58
ccs 24
cts 24
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 19 19 2
A isSuccessful() 0 4 1
A filterRequestParameters() 16 16 1
A xmlAttributesToArray() 12 12 3

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
 * @author Nicolas Clavaud <[email protected]>
4
 */
5
6
namespace Ogone\DirectLink;
7
8
use Ogone\AbstractPaymentResponse;
9
use SimpleXMLElement;
10
use InvalidArgumentException;
11
12
class DirectLinkQueryResponse extends AbstractPaymentResponse
13
{
14
15 9 View Code Duplication
    public function __construct($xml_string)
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...
16
    {
17 9
        libxml_use_internal_errors(true);
18
19 9
        if (simplexml_load_string($xml_string)) {
20 7
            $xmlResponse = new SimpleXMLElement($xml_string);
21
22 7
            $attributesArray = $this->xmlAttributesToArray($xmlResponse->attributes());
23
24
            // use lowercase internally
25 7
            $attributesArray = array_change_key_case($attributesArray, CASE_UPPER);
26
27
            // filter request for Ogone parameters
28 7
            $this->parameters = $this->filterRequestParameters($attributesArray);
29
30
        } else {
31 2
            throw new InvalidArgumentException("No valid XML-string given");
32
        }
33 7
    }
34
35 1
    public function isSuccessful()
36
    {
37 1
        return (0 == $this->getParam('NCERROR'));
38
    }
39
40 7 View Code Duplication
    protected function filterRequestParameters(array $httpRequest)
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...
41
    {
42 7
        return array_intersect_key(
43 7
            $httpRequest,
44 7
            array_flip(
45 7
                array_merge(
46 7
                    $this->ogoneFields,
47
                    array(
48 7
                        'PAYIDSUB',
49
                        'NCSTATUS',
50
                        'NCERRORPLUS',
51
                    )
52
                )
53
            )
54
        );
55
    }
56
57 7 View Code Duplication
    private function xmlAttributesToArray($attributes)
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...
58
    {
59 7
        $attributesArray = array();
60
61 7
        if (count($attributes)) {
62 7
            foreach ($attributes as $key => $value) {
63 7
                $attributesArray[(string)$key] = (string)$value;
64
            }
65
        }
66
67 7
        return $attributesArray;
68
    }
69
}
70