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::filterRequestParameters()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16

Duplication

Lines 16
Ratio 100 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 16
loc 16
ccs 7
cts 7
cp 1
rs 9.7333
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
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