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.

MaintenanceOperation   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 18.18 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 8
loc 44
ccs 17
cts 17
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 12 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 MaintenanceOperation
6
{
7
    const OPERATION_AUTHORISATION_RENEW = 'REN';
8
    const OPERATION_AUTHORISATION_DELETE = 'DEL';
9
    const OPERATION_AUTHORISATION_DELETE_AND_CLOSE = 'DES';
10
    const OPERATION_CAPTURE_PARTIAL = 'SAL';
11
    const OPERATION_CAPTURE_LAST_OR_FULL = 'SAS';
12
    const OPERATION_REFUND_PARTIAL = 'RFD';
13
    const OPERATION_REFUND_LAST_OR_FULL = 'RFS';
14
15
    protected $operation;
16
17 8 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...
18
    {
19 8
        if(!in_array($operation, self::getAllAvailableOperations())) {
20 2
            throw new \InvalidArgumentException('Unknown Operation: ' . $operation);
21
        }
22
23 6
        $this->operation = $operation;
24 6
    }
25
26 1
    public function equals(MaintenanceOperation $other)
27
    {
28 1
        return $this->operation === $other->operation;
29
    }
30
31 5
    public function __toString()
32
    {
33 5
        return (string) $this->operation;
34
    }
35
36 8
    private function getAllAvailableOperations()
37
    {
38
        return array(
39 8
            self::OPERATION_AUTHORISATION_RENEW,
40 8
            self::OPERATION_AUTHORISATION_DELETE,
41 8
            self::OPERATION_AUTHORISATION_DELETE_AND_CLOSE,
42 8
            self::OPERATION_CAPTURE_PARTIAL,
43 8
            self::OPERATION_CAPTURE_LAST_OR_FULL,
44 8
            self::OPERATION_REFUND_PARTIAL,
45 8
            self::OPERATION_REFUND_LAST_OR_FULL,
46
        );
47
    }
48
}