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.

PaymentOperation   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 21.05 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 8
loc 38
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 8 8 2
A equals() 0 4 1
A __toString() 0 4 1
A getAllAvailableOperations() 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
namespace Ogone\DirectLink;
3
4
5
class PaymentOperation
6
{
7
    const REQUEST_FOR_AUTHORISATION = 'RES';
8
    const REQUEST_FOR_DIRECT_SALE = 'SAL';
9
    const REFUND = 'RFD';
10
    const REQUEST_FOR_PRE_AUTHORISATION = 'PAU';
11
12
    protected $operation;
13
14 7 View Code Duplication
    public function __construct($operation)
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...
15
    {
16 7
        if(!in_array($operation, self::getAllAvailableOperations())) {
17 2
            throw new \InvalidArgumentException('Unknown Operation: ' . $operation);
18
        }
19
20 5
        $this->operation = $operation;
21 5
    }
22
23 1
    public function equals(PaymentOperation $other)
24
    {
25 1
        return $this->operation === $other->operation;
26
    }
27
28 4
    public function __toString()
29
    {
30 4
        return (string) $this->operation;
31
    }
32
33 7
    public function getAllAvailableOperations()
34
    {
35
        return array(
36 7
            self::REQUEST_FOR_AUTHORISATION,
37 7
            self::REQUEST_FOR_DIRECT_SALE,
38 7
            self::REFUND,
39 7
            self::REQUEST_FOR_PRE_AUTHORISATION
40
        );
41
    }
42
}