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.

DirectLinkPaymentRequest   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 71
Duplicated Lines 9.86 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 68.57%

Importance

Changes 0
Metric Value
wmc 12
lcom 1
cbo 2
dl 7
loc 71
ccs 24
cts 35
cp 0.6857
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getRequiredFields() 0 6 1
A getValidOgoneUris() 0 4 1
A setUserId() 7 7 2
A setPassword() 0 4 1
A setPswd() 0 7 2
A setAlias() 0 4 1
A setEci() 0 4 1
A setCvc() 0 4 1
A getValidOperations() 0 9 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
 * 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\AbstractPaymentRequest;
14
use Ogone\ShaComposer\ShaComposer;
15
use InvalidArgumentException;
16
17
class DirectLinkPaymentRequest extends AbstractPaymentRequest
18
{
19
20
    const TEST = "https://secure.ogone.com/ncol/test/orderdirect.asp";
21
    const PRODUCTION = "https://secure.ogone.com/ncol/prod/orderdirect.asp";
22
23 8
    public function __construct(ShaComposer $shaComposer)
24
    {
25 8
        $this->shaComposer = $shaComposer;
26 8
        $this->ogoneUri = self::TEST;
27 8
    }
28
29 5
    public function getRequiredFields()
30
    {
31
        return array(
32 5
            'pspid', 'currency', 'amount', 'orderid', 'userid', 'pswd'
33
        );
34
    }
35
36 2
    public function getValidOgoneUris()
37
    {
38 2
        return array(self::TEST, self::PRODUCTION);
39
    }
40
41 6 View Code Duplication
    public function setUserId($userid)
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...
42
    {
43 6
        if (strlen($userid) < 2) {
44 1
            throw new InvalidArgumentException("User ID is too short");
45
        }
46 5
        $this->parameters['userid'] = $userid;
47 5
    }
48
49
    /** Alias for setPswd() */
50 5
    public function setPassword($password)
51
    {
52 5
        $this->setPswd($password);
53 5
    }
54
55 6
    public function setPswd($password)
56
    {
57 6
        if (strlen($password) < 8) {
58 1
            throw new InvalidArgumentException("Password is too short");
59
        }
60 5
        $this->parameters['pswd'] = $password;
61 5
    }
62
63 1
    public function setAlias(Alias $alias)
64
    {
65 1
        $this->parameters['alias'] = $alias->__toString();
66 1
    }
67
68
    public function setEci(Eci $eci)
69
    {
70
        $this->parameters['eci'] = (string) $eci;
71
    }
72
73
    public function setCvc($cvc)
74
    {
75
        $this->parameters['cvc'] = $cvc;
76
    }
77
78
    protected function getValidOperations()
79
    {
80
        return array(
81
            PaymentOperation::REQUEST_FOR_AUTHORISATION,
82
            PaymentOperation::REQUEST_FOR_DIRECT_SALE,
83
            PaymentOperation::REFUND,
84
            PaymentOperation::REQUEST_FOR_PRE_AUTHORISATION,
85
        );
86
    }
87
}
88