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.

DirectLinkPaymentResponse   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 86.11 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 31
loc 36
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 19 19 2
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
 * This file is part of the Marlon Ogone package.
4
 *
5
 * (c) Marlon BVBA <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Ogone\DirectLink;
12
13
use Ogone\AbstractPaymentResponse;
14
use SimpleXMLElement;
15
use InvalidArgumentException;
16
17
class DirectLinkPaymentResponse extends AbstractPaymentResponse
18
{
19
20 18 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...
21
    {
22 18
        libxml_use_internal_errors(true);
23
24 18
        if (simplexml_load_string($xml_string)) {
25 14
            $xmlResponse = new SimpleXMLElement($xml_string);
26
27 14
            $attributesArray = $this->xmlAttributesToArray($xmlResponse->attributes());
28
29
            // use lowercase internally
30 14
            $attributesArray = array_change_key_case($attributesArray, CASE_UPPER);
31
32
            // filter request for Ogone parameters
33 14
            $this->parameters = $this->filterRequestParameters($attributesArray);
34
35
        } else {
36 4
            throw new InvalidArgumentException("No valid XML-string given");
37
        }
38 14
    }
39
40 14 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...
41
    {
42 14
        $attributesArray = array();
43
44 14
        if (count($attributes)) {
45 14
            foreach ($attributes as $key => $value) {
46 14
                $attributesArray[(string)$key] = (string)$value;
47
            }
48
        }
49
50 14
        return $attributesArray;
51
    }
52
}
53