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.
Completed
Pull Request — master (#68)
by Marc
08:42
created

PortDefinition   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 40 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 54.55%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 14
loc 35
ccs 6
cts 11
cp 0.5455
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 11 2
A jsonSerialize() 8 8 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
 * @package: chapi
4
 *
5
 * @author: bthapaliya
6
 * @since: 2016-10-16
7
 *
8
 */
9
namespace Chapi\Entity\Marathon\AppEntity;
10
11
use Chapi\Entity\Marathon\MarathonEntityUtils;
12
13
class PortDefinition implements \JsonSerializable
14
{
15
    const DIC = self::class;
16
    public $port = 0;
17
18
    public $protocol = 'tcp';
19
20
    public $name = null;
21
22
    public $labels = null;
23
24 2
    public function __construct($aData = [])
25
    {
26 2
        MarathonEntityUtils::setAllPossibleProperties((array)$aData, $this);
27 2 View Code Duplication
        if(isset($aData['labels']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
28
        {
29 1
            $this->labels = (object)$aData['labels'];
30
        } else {
31 1
            $this->labels = (object)[];
32
        }
33
34 2
    }
35
36
    /**
37
     * @inheritdoc
38
     */
39 View Code Duplication
    function jsonSerialize()
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...
40
    {
41
        $_aRet = (array) $this;
42
        $_aRet = array_filter($_aRet, function($v, $k) {
0 ignored issues
show
Unused Code introduced by
The parameter $k is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
43
            return !is_null($v);
44
        }, ARRAY_FILTER_USE_BOTH );
45
        return $_aRet;
46
    }
47
}